Re: [PHP] String parsing issue in PHP 4.3.10?
On Wednesday 22 December 2004 08:18, John Holmes wrote: It is, I guess. ?php $a = ' ? '; $b = ' ? '; ? will work just fine. If you try to comment out either line, though, the PHP processing will end at the ? and spit out the rest as plain text. So, text can have as many ? as you want and the only issue comes when you try to comment one of them out. I'm sure it must be documented behaviour, because my syntax highlighting editor seems to be aware of it. When I stick // in front of $a, the colour for comments stop just before the ?. And a quick check of the manual confirms that it is documented behaviour. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The 357.73 Theory: Auditors always reject expense accounts with a bottom line divisible by 5. unts */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String parsing issue in PHP 4.3.10?
* Thus wrote Jason Wong: On Wednesday 22 December 2004 08:18, John Holmes wrote: It is, I guess. ?php $a = ' ? '; $b = ' ? '; ? will work just fine. If you try to comment out either line, though, the PHP processing will end at the ? and spit out the rest as plain text. So, text can have as many ? as you want and the only issue comes when you try to comment one of them out. I'm sure it must be documented behaviour, because my syntax highlighting editor seems to be aware of it. When I stick // in front of $a, the colour for comments stop just before the ?. And a quick check of the manual confirms that it is documented behaviour. http://php.net/language.basic-syntax.comments snip The one-line comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first. /snip Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String parsing issue in PHP 4.3.10?
Jason Wong wrote: On Wednesday 22 December 2004 03:53, Richard Lynch wrote: ? can be caught by PHP as the end of PHP mode, no matter where you put it in a string or not. You can't be serious? Or have I misunderstood you? ?php echo '?php ?'; ? Works as expected, ie displays ?php ?. I plead sleep deprivation, your honor. :-^ It's only in comments that ? gets funky. Though my solution *DOES* work to solve the given problem, no? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String parsing issue in PHP 4.3.10?
From: Steve Brown [EMAIL PROTECTED] Unexpected results: If line 16 (indicated below) is commented out, the '?' in the string on line 17 makes PHP stop parsing and the rest of the script is simply dumped to stdout. If line 16 is NOT commented out, the '?' is NOT picked up as being a PHP tag and it parses the script as PHP. Quote: The one-line comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first. This means that HTML code after // ? WILL be printed: ? skips out of the PHP mode and returns to HTML mode, and // cannot influence that. If asp_tags configuration directive is enabled, it behaves the same with // %. From: http://www.php.net/manual/en/language.basic-syntax.comments.php I remember running into this, also, so don't feel bad about not noticing it. ;) ---John Holmes... UCCASS - PHP Survey System http://www.bigredspark.com/survey.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String parsing issue in PHP 4.3.10?
On Wednesday 22 December 2004 01:12, Steve Brown wrote: I'm working on a script that will parse through a long string using regexs to pattern match a certain format. I'm having an issue with a '?' in a string being picked up as an end-of-code character, but only if the line before it is commented out. If the line before is NOT commented out, PHP processes the file as normal (errors out, but I can fix that). That suggests to me you have some mismatched quotes somewhere. Get yourself an editor that does syntax highlighting then you can easily see where your quoted strings begin and end. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Minnie Mouse is a slow maze learner. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String parsing issue in PHP 4.3.10?
Quote: The one-line comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first. This means that HTML code after // ? WILL be printed: ? skips out of the PHP mode and returns to HTML mode, and // cannot influence that. If asp_tags configuration directive is enabled, it behaves the same with // %. I read that too, but my problem is with the fact that if the previous line is NOT commented out, the script works fine. You will notice that the previous line also contains a '?' sequence, so I'm confused as to why this would die on one line but not the other? Or is this some freak combination of comments and PHP tags? :-o At any rate, I managed to work around this issue by encapsulating the '\s?' partion of the expression in parentheses. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String parsing issue in PHP 4.3.10?
Steve Brown wrote: I'm working on a script that will parse through a long string using regexs to pattern match a certain format. I'm having an issue with a '?' in a string being picked up as an end-of-code character, but only No need to run it. ? can be caught by PHP as the end of PHP mode, no matter where you put it in a string or not. You can get around this by using something like: //$note_exp = '/\d{1,2} \w{3} \d{4} \d{2}:\d{2}\s? [!-~ ]+/'; // COMMENT OUT THIS LINE $note_exp = '/\d{1,2} \w{3} \d{4} \d{2}:\d{2}\s?' . ' [!-~]+/'; Other possible solutions: Use ?\ and PHP inside of and maybe PHP will interpret that as what you want. I'm also not a fan of a single \ inside of '' myself, even if the manual has finally said it's kosher. Maybe cuz I'm just old, and remember when that was not specifically allowed in the manual. :-) So I'd use \\ everywhere you have \ currently. Actually, you may be triggering a PHP bug in the string parsing engine, by using \ instead of \\. You do realize that \ *IS* one of the two special characters inside of ''s, the other being ' itself, right?... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String parsing issue in PHP 4.3.10?
On Wednesday 22 December 2004 03:53, Richard Lynch wrote: ? can be caught by PHP as the end of PHP mode, no matter where you put it in a string or not. You can't be serious? Or have I misunderstood you? ?php echo '?php ?'; ? Works as expected, ie displays ?php ?. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The typewriting machine, when played with expression, is no more annoying than the piano when played by a sister or near relation. -- Oscar Wilde */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] String parsing issue in PHP 4.3.10?
You will notice that the previous line also contains a '?' sequence, so I'm confused as to why this would die on one line but not the other? Or is this some freak combination of comments and PHP tags? :-o It is, I guess. ?php $a = ' ? '; $b = ' ? '; ? will work just fine. If you try to comment out either line, though, the PHP processing will end at the ? and spit out the rest as plain text. So, text can have as many ? as you want and the only issue comes when you try to comment one of them out. ---John Holmes... UCCASS - PHP Survey System http://www.bigredspark.com/survey.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php