Re: [PHP] Custom Open Tags
On Wed, 01 Dec 2004 23:25:00 +0100, M. Sokolewicz [EMAIL PROTECTED] wrote: I think patching zend_language_scanner.l would be easier actually ;) Probably getting a little off-topic here but after I saw how seemingly easy this might be, I had to give it a shot. I added this in Zend/zend_language_scanner.l file just under the similar ?php block: INITIAL?new([ \t]|{NEWLINE}) { zendlval-value.str.val = yytext; /* no copying - intentional */ zendlval-value.str.len = yyleng; zendlval-type = IS_STRING; HANDLE_NEWLINE(yytext[yyleng-1]); BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG; } My vanilla ./configure ends with no errors, but when I compile it it dies with: sapi/cgi/cgi_main.o(.text+0x1499): In function `main': /home/greg/php-5.0.2/sapi/cgi/cgi_main.c:1580: undefined reference to `open_file_for_scanning' sapi/cgi/cgi_main.o(.text+0x150b):/home/greg/php-5.0.2/sapi/cgi/cgi_main.c:1591: undefined reference to `open_file_for_scanning' collect2: ld returned 1 exit status make: *** [sapi/cgi/php] Error 1 I'm using PHP 5.02 source on a Debian sarge box. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Custom Open Tags
I think there's a way to redefine what tag PHP uses, but I think it globally resets it. I don't think you can say use !blah ! and also use ?php ?. I think that setting is in PHP.INI somewhere. It might be easier to change your to be executed later php tags to something else and before it's sent to it's final destination, do a string replace to change the tags. If you have two different servers, you might go into PHP.INI and set the following tag on the last server and turn it OFF on the first server: ; Allow ASP-style % % tags. asp_tags = Off I'm not sure, but that may allow you to use ?php ? AND % % tags at the same time. All in all, I think I'd try to find a better way than using two kinds of tags and trying to jury-rig PHP to only execute some of it. Even if it meant using a conditional on the tags to be executed later if (!$finalexecute) ... and just change that value at the top of your code or something. Sounds messy all around, but there seem to be a number of ways you could possibly do this. -TG -Original Message- From: Sven Schwyn [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 4:16 PM To: [EMAIL PROTECTED] Subject: [PHP] Custom Open Tags Hi folks Does anybody know whether there's a way to tell PHP to accept an alternative open tag like for instance ?mytag or ?mc along with the normal ?php tag? I'm looking for a way to have two kinds of PHP code in a page. The first kind tagged ?mc ... ? contains the PHP code to manage page elements (like includes, menus etc) while the second kind tagged ?php ... ? contains normal PHP code for dynamic pages (like DB stuff). A page resides on the Staging (Virtual) Host and contains both kind of tags. When viewing the page on the Staging Host, both open tags are executed. Yet when publishing a page to the Production (Virtual) Host, the mc-tags are executed (and thus complete the page design) while the php-tags are left untouched (as they contain the dynamic stuff). Sounds more complicated than it is :-) Thanks for your hints,-sven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
Sven Schwyn wrote: Hi folks Does anybody know whether there's a way to tell PHP to accept an alternative open tag like for instance ?mytag or ?mc along with the normal ?php tag? I'm looking for a way to have two kinds of PHP code in a page. The first kind tagged ?mc ... ? contains the PHP code to manage page elements (like includes, menus etc) while the second kind tagged ?php ... ? contains normal PHP code for dynamic pages (like DB stuff). A page resides on the Staging (Virtual) Host and contains both kind of tags. When viewing the page on the Staging Host, both open tags are executed. Yet when publishing a page to the Production (Virtual) Host, the mc-tags are executed (and thus complete the page design) while the php-tags are left untouched (as they contain the dynamic stuff). Sounds more complicated than it is :-) I don't think you can do that in any efficient way with just tweaking PHP settings, or even PHP source... What you *COULD* do is write a PHP script to read your PHP script and http://php.net/eval the stuff inside of ?mytag tags, and leave the rest alone for the real PHP server to handle... ?php //Untested code: $file = implode('', file($php_source)); $parts = explode('?mytag', $file); $result = $part[0]; unset($parts[0]); while (list(, $part) = each($parts)){ $phphtml = explode('mytag?', $part); $php = $phphtml[0]; $html = @$phphtml[1]; //File may end with mytag? so squash error $result .= eval($php); $result .= $html; } //Dump $result into some file somewhere... ? Sounds like you inventing yet another Template language, though, to tell you the truth, and there's already too many of them. :-) I happen to think PHP all by itself is more than sufficient, and if Graphic Designers can't cope with ignore the PHP tags, just hire different Graphic Designers. :-) You may want to look at Smarty and phplip (?) and some of the dozens of other PHP-based template solutions. Just cuz I hate them doesn't mean you will. :-P -- 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] Custom Open Tags
Hi Trevor I'm not sure, but that may allow you to use ?php ? AND % % tags at the same time. Thought about that, it would actually be very elegant if it was the other way round. ASP tags would be great instead of a ?mc ... ? custom tag, however, that won't do the trick as the execution of the ?php ... ? tags can't be switched off (or can it?) when using % ... % tags. Thanks for your thoughts though! -sven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
On Wed, 1 Dec 2004 22:16:25 +0100, Sven Schwyn [EMAIL PROTECTED] wrote: Does anybody know whether there's a way to tell PHP to accept an alternative open tag like for instance ?mytag or ?mc along with the normal ?php tag? Patch zend_language_scanner.c and add you own custom tags. Isn't open source great? :) -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
you could edit the parser rules manually, recompile PHP and it should work Sven Schwyn wrote: Hi Trevor I'm not sure, but that may allow you to use ?php ? AND % % tags at the same time. Thought about that, it would actually be very elegant if it was the other way round. ASP tags would be great instead of a ?mc ... ? custom tag, however, that won't do the trick as the execution of the ?php ... ? tags can't be switched off (or can it?) when using % ... % tags. Thanks for your thoughts though! -sven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
You could always patch zend_language_scanner.c and add your own custom tags. Isn't open source great? :) -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
Greg Donald wrote: You could always patch zend_language_scanner.c and add your own custom tags. Isn't open source great? :) I think patching zend_language_scanner.l would be easier actually ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php