thomseddon Posted June 21, 2008 Share Posted June 21, 2008 ok so i have always used something like this: <?php $name = "thom"; ?> <html> my name is: <?=$name?> </html> expecting the output just to be: my name is: thom but i have recently moved to a new host and i cannot use this, in this example i would just get my name is: why is this? i am told php5 is installed should i ask them to reinstall it, is there an alternative function? (tia!!) Link to comment https://forums.phpfreaks.com/topic/111259-solved-show-variable-in-html/ Share on other sites More sharing options...
phpSensei Posted June 21, 2008 Share Posted June 21, 2008 That is some bad coding practice. try Code: <?php $name = "thom"; ?> <html> my name is: <?php echo $name; ?> </html> Link to comment https://forums.phpfreaks.com/topic/111259-solved-show-variable-in-html/#findComment-571055 Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 Indeed. You were using "short tags" to echo it, which is sloppy, not guaranteed to work on all servers (obviously), and lazy. thebadbad showed the proper way to do it. Link to comment https://forums.phpfreaks.com/topic/111259-solved-show-variable-in-html/#findComment-571056 Share on other sites More sharing options...
thomseddon Posted June 21, 2008 Author Share Posted June 21, 2008 my bad!!! so why is it different on different servers!? i never realised it was naughty script!!! (guess that what come from teaching yourself lol) Link to comment https://forums.phpfreaks.com/topic/111259-solved-show-variable-in-html/#findComment-571059 Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 Because most servers these days turn off the short tags directive in php.ini. =P Link to comment https://forums.phpfreaks.com/topic/111259-solved-show-variable-in-html/#findComment-571061 Share on other sites More sharing options...
dannyb785 Posted June 21, 2008 Share Posted June 21, 2008 Yep... just one of them things Link to comment https://forums.phpfreaks.com/topic/111259-solved-show-variable-in-html/#findComment-571121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.