Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.