note 125335 added to language.basic-syntax.phpmode

From: Date: Sat, 05 Sep 2020 19:15:51 +0000
Subject: note 125335 added to language.basic-syntax.phpmode
Groups: php.notes 
Request: Send a blank email to php-notes+get-215079@lists.php.net to get a copy of this message
When the PHP interpreter hits the ?> closing tags, it WON'T output right away if it's inside of a conditional statement: (no matter if it's an Alternative Syntax or not) <html> <?php $a = 1; $b = 2; if ($a === 1) { if ($b == 2) { ?><head></head><?php } else { ?><body></body><?php } } ?> </html> This would output <html><head></head></html>. Aside from conditional statements, the PHP interpreter also skip over functions! What a surprise! <html> <?php function show($a) { ?> <a href="https://www.<?php echo $a ?>.com"> Link </a> <?php } ?> <body> <?php show("google") ?> </body> </html> This gives <html><body><a href="https://www.google.com">Link</a></body></html>. These really confused me, because at first I thought it would output any HTML code right away, except for Alternative Syntaxes (https://www.php.net/manual/en/control-structures.alternative-syntax.php). There are more strange cases than I thought. ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.167.36 (proxied: 180.217.179.20) ---- Manual Page -- http://php.net/manual/en/language.basic-syntax.phpmode.php Edit -- https://master.php.net/note/edit/125335 Del: integrated -- https://master.php.net/note/delete/125335/integrated Del: useless -- https://master.php.net/note/delete/125335/useless Del: bad code -- https://master.php.net/note/delete/125335/bad+code Del: spam -- https://master.php.net/note/delete/125335/spam Del: non-english -- https://master.php.net/note/delete/125335/non-english Del: in docs -- https://master.php.net/note/delete/125335/in+docs Del: other reasons-- https://master.php.net/note/delete/125335 Reject -- https://master.php.net/note/reject/125335 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215079) next »