Simply, your question sounded wrong because the JavaScript variables need to be echoed.
<?php_x000D_
$num = 1;_x000D_
echo $num;_x000D_
echo "<input type='button' value='Click' onclick='readmore()' />";_x000D_
echo "<script> function readmore() { document.write('";_x000D_
$num = 2;_x000D_
echo $num;_x000D_
echo "'); } </script>";_x000D_
?>
_x000D_