I am doing some php programming (so I can learn it) One methode to use html in php is with echo. For one or two lines, its a good way. But what about a whole page? Is there a alternative to using echo?
Yes, similarly you could use print_r('STUFF HERE'); for a whole page though, I would just escape the PHP and use this: <?php echo " ?> all your HTML stuff goes here <?php "; ?> Code (markup): Some of that nature.
All you need is <?php //here's my fun php code, where i'm doing lots of stuff ?> Now just plain jane html here, but i wanted to display a variable, or some other php code, i could do <?php echo substr($myvar, 0, 6) ?> right in the middle of my html. <?php //some more php stuff... ?> Code (markup): You can also include line returns in your echo statements so you could do this (which is what I think you're asking) echo "<Table> <tr> <td> Title </td> <td> Descrip. </td> <td> Price </td> </tr> </table>"; Code (markup): You should only use print_r for testing (seeing what's stored in an array for example). Use echo or print to display anything else. -the mole
For a whole page there's no problem using print and echo with breaks back into pure html (as discussed above). I have some very old php speed tests you may want to check out but in reality the real impact will be in the image sizes, overall page size, server performance and the users dialup/broadband connection. For larger systems where there's alot of logic and alot going on consider the following strategies: Using a templating system like smarty - this makes it easier to manage but ultimately smarty uses echo too having the logic at the top of the script and all presentation work at the bottom of the script having 2 scripts, one includes files, gets all the data, copes with permissions etc, the other turns them into pages - this approach is used by Mambo/Joomla