I'm using Drupal, and on one of my pages I have to input some PHP code, and within that PHP code I want to insert an HTML comment that looks like this: <!--pagebreak--> PHP: This comment activates a function in another module that splits the page up into to separate pages. The reason I need it within the PHP code and not in between two separate <?php ... ?> blocks is because the code before and the code after the HTML comment need the same variables. If I just do a normal print statement PHP basically ignores the whole comment and goes straight to the ; at the end of the line and gives me an 'unexpected $end' error. So what I want to do is to be able to put that HTML comment within the confines of a block of PHP code and still have it parse as it would if it was outside the block of PHP code.
I think you're misunderstanding the scope of php. If you create a variable in the global scope in any php snippet, it'll be available anywhere further on the page in the global scope. Closing the php block and opening a new one doesn't kill all of the existing variables. <?php $x = "Roar!"; ?> ... random html here ... <?php echo $x; // This outputs "Roar!" ?> PHP: You must have made a typo. I was able to output <!-- pagebreak --> just fine with both print and echo. echo "<!-- pagebreak -->"; PHP: Good luck, - Walkere
Well there are different ways: An IF Statement if your achieving that. <?php if($something){ echo "<!-pagebreak-->"; } else { echo "Something Else"; } PHP: A simple echo <?php echo "<!-pagebreak-->"; ?> PHP: Something Else <?php if($something){ $x = "<!--pagebreak-->"; } else { $x = "SOMETHING ELSE"; } echo $x; ?> PHP: