note 126533 added to language.basic-syntax.phptags

From: Date: Sun, 24 Oct 2021 02:28:14 +0000
Subject: note 126533 added to language.basic-syntax.phptags
Groups: php.notes 
Request: Send a blank email to php-notes+get-217106@lists.php.net to get a copy of this message
If you want your file to be interpreted as php then your file must start and end with <?php and ?> and everything outside of that is ignored by the php parser. <?php php code..//parsed php code..//parsed ?> hellow..//normal test but ignred by php parser Three types of tag are available in php 1.normal tag(<?php ?>) 2.short echo tag(<?= ?>) 3.short tag(<? ?>) short tag are bydefault available but can be disabled by short_open_tag = Off and also disabled bydefault if php will built with --disabe--short--tags() As short tag can be disabled so only use the normal and short echo tag. If your file only have php code then do not use closing tag. <?php //php code; //php code; //php code; but if you are embedding php with html then enclose php code with opening and closing tag. <html> <head> </head> <body> <?php //php code; //php code; //php code; ?> </body> </html> If you want to just print single text or something ,you should use shorthand version .<?= $var ?> But if you want to process something, you should use normal tag. <?php //$var = 3; //$var2 = 2; //$var3 = $var+$var2; //if($var3){//result} ?> If you embedded php with html and single line, do not need to use semicolon <html> <head> <body> <?= $var ?> </body> </head> </html> but if you have multiple line, then use semicolon. <?php //line 1; //line 2; //line 3; ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 103.120.33.26) ---- Manual Page -- https://php.net/manual/en/language.basic-syntax.phptags.php Edit -- https://main.php.net/note/edit/126533 Del: integrated -- https://main.php.net/note/delete/126533/integrated Del: useless -- https://main.php.net/note/delete/126533/useless Del: bad code -- https://main.php.net/note/delete/126533/bad+code Del: spam -- https://main.php.net/note/delete/126533/spam Del: non-english -- https://main.php.net/note/delete/126533/non-english Del: in docs -- https://main.php.net/note/delete/126533/in+docs Del: other reasons-- https://main.php.net/note/delete/126533 Reject -- https://main.php.net/note/reject/126533 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217106) next »