Jump to content

Tricking PHP


me1000

Recommended Posts

ok i have to define a variable but i want the contents to be visible in a WYSIWYG editor,

so this is what i have come up with

[code]<?

$pagecode=
?>
<HTML>
lalalalal
</HTML>
<?
;
?>[/code]
since I closed the PHP tags the WYSIWYG editor shows it in the editing window

however this doesnt work i get this error

Parse error: parse error, unexpected ';' in /home/startr5/public_html/template/1.php on line 9

this is 1.php
[code]<?
$id = "1" ;
$title = "Main Page" ;
$restricted = "0 " ;
$keywords = "home page main " ;
$type = "1" ;

$pagecode =
?>
<lots of HTML>
<?
;
?>[/code]

line 9 is the first "?>" tag there...


any ideas how to get around this???



Thanks,

Link to comment
https://forums.phpfreaks.com/topic/28485-tricking-php/
Share on other sites

WYSIWYG editors and PHP really do not get along. If you're going to write PHP that generates HTML code, learn how to write good HTML code by hand and don't try to warp what PHP does.

That being said, using the [url=http://www.php.net/manual/en/language.types.string.php]Heredoc format[/url] (about 1/2 way down the page) might be what you're looking for.

[code]<?php
$some_var = <<<EOT
<lots of html>
EOT;
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/28485-tricking-php/#findComment-130364
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.