CyberShot Posted January 10, 2009 Share Posted January 10, 2009 I am learning php. Just started. I was messing with echo and I found that if you do <?php echo "hello world"; ?> it prints hello world. but if you do <?php echo "hello world"; echo "hello again"; ?> You get an error. can anyone tell me why? Link to comment https://forums.phpfreaks.com/topic/140326-solved-php-coding-question/ Share on other sites More sharing options...
Mark Baker Posted January 10, 2009 Share Posted January 10, 2009 Can't see anything wrong with it. What error are you getting? Link to comment https://forums.phpfreaks.com/topic/140326-solved-php-coding-question/#findComment-734296 Share on other sites More sharing options...
CyberShot Posted January 10, 2009 Author Share Posted January 10, 2009 it seems that I get the error because of a <br /> tag. <?php echo "hello world"; <br /> print "hello world"; <br /> echo "hello" . " " . "world"; <br /> echo 2+3; <br /> echo 2+9; <br />?> The tutorial I am watching says that the server wouldn't care about the br tag. but it does in this version Link to comment https://forums.phpfreaks.com/topic/140326-solved-php-coding-question/#findComment-734305 Share on other sites More sharing options...
Mark Baker Posted January 10, 2009 Share Posted January 10, 2009 <br /> is part of what you're trying to output using echo: <?php echo "hello world<br />"; print "hello world<br />"; echo "hello" . " " . "world<br />"; echo (2+3)."<br />"; echo (2+9)."<br />"; ?> Link to comment https://forums.phpfreaks.com/topic/140326-solved-php-coding-question/#findComment-734306 Share on other sites More sharing options...
ILMV Posted January 10, 2009 Share Posted January 10, 2009 There is nothing syntactically wrong with your code, as far as the PHP server is concernerd it will print it out like this... 'hello world' and then 'hello again' right after. Link to comment https://forums.phpfreaks.com/topic/140326-solved-php-coding-question/#findComment-734308 Share on other sites More sharing options...
CyberShot Posted January 10, 2009 Author Share Posted January 10, 2009 ok, that makes sense. thanks. Link to comment https://forums.phpfreaks.com/topic/140326-solved-php-coding-question/#findComment-734309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.