<script type="..."> support

From: Date: Tue, 14 Aug 2001 21:07:00 +0000
Subject: <script type="..."> support
Groups: php.dev 
Request: Send a blank email to php-dev+get-63179@lists.php.net to get a copy of this message
PHP (or, rather, the Zend scanner) currently recognizes the following tags as enclosing PHP code: <?php ?> <? ?> <% %> <script language="php"> The attached patch extends the <script> tag to also except the <script type="..."> syntax, where the type is the MIME type signifying PHP code (application/x-httpd-php). The 'type=".."' attribute is necessary for XHTML 1.0 compliance. The idea for this addition originated from "Alexander J. Vincent" <ajvincent@hotmail.com>. I've also attached a short test script to demonstrate the new behavior. If this patch is accepted, I can also make the appropriate documentation changes. -- Jon Parise (jon@csh.rit.edu) . Rochester Inst. of Technology http://www.csh.rit.edu/~jon/ : Computer Science House Member

Index: zend_language_scanner.l =================================================================== RCS file: /repository/Zend/zend_language_scanner.l,v retrieving revision 1.35 diff -u -r1.35 zend_language_scanner.l --- zend_language_scanner.l 2001/08/11 15:57:07 1.35 +++ zend_language_scanner.l 2001/08/14 20:59:26 @@ -1073,7 +1073,7 @@ return T_INLINE_HTML; } -<INITIAL>"<?"|"<script"{WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"\'php\'"){WHITESPACE}*">" { +<INITIAL>"<?"|"<script"({WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"\'php\'")|{WHITESPACE}+"type"{WHITESPACE}*"="{WHITESPACE}*("application/x-httpd-php"|"\"application/x-httpd-php\""|"\'application/x-httpd-php\'"))+{WHITESPACE}*">" { HANDLE_NEWLINES(yytext, yyleng); if (CG(short_tags) || yyleng>2) { /* yyleng>2 means it's not <? but <script> */ zendlval->value.str.val = yytext; /* no copying - intentional */ <?php echo '<h2>&lt;?php ?&gt;</h2>'; ?> <? echo '<h2>&lt;? ?&gt;</h2>'; ?> <?= '<h2>&lt;?= ?&gt;</h2>'; ?> <script language="php"> echo '<h2>language="php"</h2>'; </script> <script type="application/x-httpd-php"> echo '<h2>type="application/x-httpd-php"</h2>'; </script> <script language="php" type="application/x-httpd-php"> echo '<h2>language="php" type="application/x-httpd-php"</h2>'; </script>
« previous php.dev (#63179) next »