It looks like you need to enable short_open_tag if your example is not working.
<?php ini_set('short_open_tag', 'on'); $url='test.php'; ?> <html> <body> <form name="upload" action="<?=$url?>" method="post" > <input type="submit" value="submit"> </form> </body> </html>
Alternatively, write it as follows:
<?php $url='test.php'; ?> <html> <body> <form name="upload" action="<?php echo $url ?>" method="post" > <input type="submit" value="submit"> </form> </body> </html>
source share