Xu Wei Jie Posted February 16, 2009 Share Posted February 16, 2009 Hi all, I need help on this. If I have a php tag <?php ?> within another php tag. How do I process the inner tag as just plain text without the CLI interpreting it? Do I need to write some config file for the CLI or do I use a flexible parser? I am clueless. Any ideas or suggestions would help. Regards, weijie Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/ Share on other sites More sharing options...
Mchl Posted February 16, 2009 Share Posted February 16, 2009 Tags enclosed in quotes are not interpreted, and I don't think you need tags outside quotes. Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-763410 Share on other sites More sharing options...
Xu Wei Jie Posted February 16, 2009 Author Share Posted February 16, 2009 Would it be a single quote or double quote? What if the inner tag also contain quotes? Won't the coding get very messy? Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-763423 Share on other sites More sharing options...
Mchl Posted February 16, 2009 Share Posted February 16, 2009 Could you show example of what you're trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-763431 Share on other sites More sharing options...
Xu Wei Jie Posted February 16, 2009 Author Share Posted February 16, 2009 It goes like this <?php echo '<?php echo $result[\'Title\'];?>' ?> I am just wondering if there is a more elegant way of doing it. Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-763435 Share on other sites More sharing options...
Mchl Posted February 16, 2009 Share Posted February 16, 2009 This should work all right. In PHP 5.3.0 the NOWDOC syntax will be introduced, which will be a bit more elegant, but until then there isn't really much more you can do about it. You might also want to check highlight_string function. Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-763444 Share on other sites More sharing options...
Xu Wei Jie Posted February 18, 2009 Author Share Posted February 18, 2009 Where do I download PHP 5.3.0 from? My current version is 5.2.8. The highlight function does not seem to be of usage as it inserts HTML codes. Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765324 Share on other sites More sharing options...
Mchl Posted February 18, 2009 Share Posted February 18, 2009 5.3.0 has not been released yet. You can download development version from php.net. Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765341 Share on other sites More sharing options...
Xu Wei Jie Posted February 18, 2009 Author Share Posted February 18, 2009 Do you have the link to the development version? I can't seem to find it on php.net. Thanks very much for your help Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765477 Share on other sites More sharing options...
premiso Posted February 18, 2009 Share Posted February 18, 2009 http://snaps.php.net/ Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765478 Share on other sites More sharing options...
Xu Wei Jie Posted February 19, 2009 Author Share Posted February 19, 2009 I am not sure how to install the development version. Thus, I tried the windows build at this link http://windows.php.net/snapshots/. However, I still cannot get it to work. It reports a PHP parse error. The test code I tried to parse according to NOWDOC syntax <?php echo <<<'EOT' echo "Hello world!" EOT; ?> Any idea? Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765836 Share on other sites More sharing options...
MasterACE14 Posted February 19, 2009 Share Posted February 19, 2009 change it to this.. <?php echo <<<EOT echo "Hello world!" EOT; ?> Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765844 Share on other sites More sharing options...
Xu Wei Jie Posted February 19, 2009 Author Share Posted February 19, 2009 There is still a parsing error on line 2 =( Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765853 Share on other sites More sharing options...
MasterACE14 Posted February 19, 2009 Share Posted February 19, 2009 try... <?php echo <<<_EOT echo "Hello world!" _EOT; ?> and what's the parse error? Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765854 Share on other sites More sharing options...
Xu Wei Jie Posted February 19, 2009 Author Share Posted February 19, 2009 I think I got it solved. I was using a notepad to edit the php file. Thus, it may introduce some unwanted new lines or returns in the nowdoc statement. So I guess I must be careful with it. Another question is that I cannot use nowdoc to create single line statements like echo <<<'EOT' test EOT;. It will still parse wrongly. Any way to work around it? Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765862 Share on other sites More sharing options...
Mchl Posted February 19, 2009 Share Posted February 19, 2009 No. That's how Nowdoc works. Read about it manual. For single lines you can just use single quotes. echo 'echo "Hello world!";'; Quote Link to comment https://forums.phpfreaks.com/topic/145424-php-tags-within-php-tags/#findComment-765892 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.