Hi all! I'm writing a PHP tutorial for my site, however I have a very anoying problem. When I try to write the tut, it always executes the php code that I'm writing for the tut. How can I stop this?? For instance, look at the example below. php_tut1.php <?php session_start(); ?> <HTML> <head> <link rel="stylesheet" type="text/css" href="style.css"> <title>Tutorial World</title> </head> <body> <p>Welcome to my PHP Tutorial!</p> <br><br><br> An example PHP file could be this: <br> <p style="border:3px solid black;"> <?php /* How do I stop the code from here:*/ echo "Hello World!"; ?> /* To Here from executing? */ </p> </body> </html> PHP: This is just an example file of a .php file that would be on my site. Basically I don't want the code that is part of the demo from executing. Anybody got any ideas? Tere must be some way of doing it because there are so many tut sites out there.
You can use the PHP heredoc syntax: phpf1.com/tutorial/php-heredoc-syntax.html <?php $str = <<<DEMO This is a demo message with heredoc. Put any formatted message in here. <?php echo "hi"; ?> hehe #!/bin/bash/ echo hi DEMO; echo $str; ?> Code (markup):
@TYPELiFE That would'dnt always work in this case. As if the php contained echo's, it would evaluate it as html, theirfore would cause conflict with the actual webpage's html. Theirfore do this: php_tut1.php <?php session_start(); ?> <HTML> <head> <link rel="stylesheet" type="text/css" href="style.css"> <title>Tutorial World</title> </head> <body> <p>Welcome to my PHP Tutorial!</p> <br><br><br> An example PHP file could be this: <br> <p style="border:3px solid black;"> <?php highlight_string('<?php echo "Hello World!"; ?>'); ?> </p> </body> </html> PHP: