Re: Re: Set Variable = Long HTML String?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You can mingle double and singal quotes.  So choose one for the PHP
quotes and one for the HTML quotes, HTML will use both interchangably.

For example your string could become:
$var = "<form name='events' ...";


I'd also look at the echo's inside the string, they look like they
shouldn't be there.


David


sit1way wrote:
> Hey all.
> 
> I'm overhauling my PHP based CMS and want to know how to set a variable 
> equal to an HTML string, but without having to escape all the quotes!

You can mingle double and singal quotes.  So choose one for the PHP
quotes and one for the HTML quotes, HTML will use both interchangably.

For example your string could become:
$var = "<form name='events' ...";


The echo's inside the string also aren't necessary.  Just use the value
directly when building the string.


David

> Example:
> 
> $var = "<form name="events" method="POST" action="">
>                         <select class="menus" name="news" 
> onChange="MM_jumpMenu('parent',this,0);">
>        <option selected>News Options</option>
>        <option value=<? echo $this->doc_path 
> ?>admin/news/add/1/>Add</option>
>        <option value=<? echo $this->doc_path 
> ?>admin/news/update/1/>Update</option>
>        <option value=<? echo $this->doc_path 
> ?>admin/news/delete/1/>Delete</option>
>       </select>
>      </form>";
> 
> This will die due to all the unescaped strings, not to mention the <? echo 
> $this->doc_path ?> statements.
> 
> How to pull this off?  I don't want to include the HTML snippets as they are 
> "sprinkled" throughout my classes.
> 
> TIA,
> 
> --Noah
> 
> 
>  
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux