OM2 Posted July 26, 2008 Share Posted July 26, 2008 Can I not escape quote characters? Not sure if I've got the correct terminology, but I mean: when you want to print "'s in your output, you have to use \". Being able to split up a page is brilliant: like having one file that is the header for all files. But, the thing is, it's really annoying editing and hard to read trying to see through all the \". The WORST thing, when editing using something like Dreamweaver: any changes have to be done manualy by looking at the code because it obviously doesn't display the code. What would be brilliant is if I could have a bog standard HTML page (maybe without the HTML, Title, Body etc tags) and then be able to simply include these pages. Hope that makes some sense! Thanks. OM Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/ Share on other sites More sharing options...
ratcateme Posted July 26, 2008 Share Posted July 26, 2008 i think what you might be looking for is Heredoc read this http://php.net/manual/en/language.types.string.php Scott. Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600074 Share on other sites More sharing options...
OM2 Posted July 26, 2008 Author Share Posted July 26, 2008 scott, thanks. that wa san intersting read. so the answer is heredocs? use <<<? so, i can have: echo <<<EOT <div class="box-title"> My text </div> EOT; ? nowdocs: used for when u do want to print ALL characters? Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600142 Share on other sites More sharing options...
OM2 Posted July 26, 2008 Author Share Posted July 26, 2008 i've added the following into dreamweaver just to test: echo <<<EOT <div class="box-title"> My text </div> EOT; it doesn't show up - but still ok, because i can now read and at least edit much more easily. is there anything i can use where i can see the actual graphical representation? ALSO, on php.net, they give an example: echo <<<EOT My name is "$name". I am printing some $foo->foo. Now, I am printing some {$foo->bar[1]}. This should print a capital 'A': \x41 EOT; now, they say the output should be: My name is "MyName". I am printing some Foo. Now, I am printing some Bar2. This should print a capital 'A': A when i try it: i dont get the newlines - everything is on one line. what am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600147 Share on other sites More sharing options...
ratcateme Posted July 26, 2008 Share Posted July 26, 2008 i am not sure what you are doing for first one i copied that code directly and it works fine. with regards to your second question the reason you don't get the line breaks is because html wont look at line breaks it only looks at <br> if you put the output inside a <pre> tag it will display the code as written in the source so change this echo <<<EOT <pre> My name is "$name". I am printing some $foo->foo. Now, I am printing some {$foo->bar[1]}. This should print a capital 'A': \x41 </pre> EOT; now the <pre> tags will make it display the line breaks. Scott. Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600527 Share on other sites More sharing options...
OM2 Posted July 27, 2008 Author Share Posted July 27, 2008 thanks for the reply scott. i've got the latest version of dreamweaver: i was blaming dreamweaver. hmmm not sure what the problem is! for the second bit... i think somewhere the formatting of your reply went funny and it was hard to read. where u saying that should start with and end with ?? i.e. [code=php:0]echo <<<EOT My name is "$name". I am printing some $foo->foo. Now, I am printing some {$foo->bar[ 1]}. This should print a capital 'A': \x41 EOT; [/code] Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600553 Share on other sites More sharing options...
MasterACE14 Posted July 27, 2008 Share Posted July 27, 2008 <?php echo <<<_PAGE <h1>My Heading</h1> <p>My Paragraph. My {$variable}</p> _PAGE; ?> enclose variables within curly braces when using the heredoc syntax Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600568 Share on other sites More sharing options...
OM2 Posted July 27, 2008 Author Share Posted July 27, 2008 ahhh... i see. but: what if dont have vaiables and just ahve text? how do u stop ur text appearing all on one line - even when it isn't given like this in php? Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600591 Share on other sites More sharing options...
ratcateme Posted July 27, 2008 Share Posted July 27, 2008 sorry something must be going on with the forums i post html tags and instead of phrasing my bbcode tags it phrased my html tags what i was trying to say was try it like this echo <<<EOT <pre> My name is "$name". I am printing some $foo->foo. Now, I am printing some {$foo->bar[1]}. This should print a capital 'A': \x41 </pre> EOT; the < pre > tag will make it look like the code boxes on this site and all your newlines will actually turn out as new lines with out having to include a < br > tag Scott. Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600634 Share on other sites More sharing options...
OM2 Posted July 27, 2008 Author Share Posted July 27, 2008 scott, thanks a lot. just from this thread: i've learnt an immense amount! Link to comment https://forums.phpfreaks.com/topic/116708-newbie-can-i-not-escape-quote-characters/#findComment-600764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.