This PHP Reference section displays the code for example programs that demonstrate how to display variable values.
<!DOCTYPE html> <html> <head> </head> <body> <?php $sOldName = "Simon"; $sNewName = "Peter"; ?> <h3>Echo</h3> <?php echo $sOldName; echo "<br/>"; echo $sNewName; echo "<br/>"; ?> <h3>Print</h3> <?php print $sOldName; print "<br/>"; print $sNewName; print "<br/>"; ?> <h3>Variables Inside Text</h3> <?php echo "Blessed are you, $sOldName Bar-Jona!<br/>"; echo "Blessed are you, ".$sOldName." Bar-Jona!<br/>"; echo "Blessed are you, {$sOldName} Bar-Jona!<br/>"; ?> <h3>PHP inside HTML</h3> <p><?php echo $sOldName ?></p> <h3>HTML inside PHP</h3> <?php echo "<p>{$sOldName}</p>"; ?> <h3>Single, Double, and No Quotes</h3> <?php echo '$sOldName'.'$sNewName'; echo "<br/>"; echo "$sOldName"."$sNewName"; echo "<br/>"; echo $sOldName.$sNewName; echo "<br/>"; echo '$sOldName'." "."$sOldName"." ".$sOldName; echo "<br/>"; ?> <h3>Var_dump</h3> <?php var_dump($sOldName); var_dump($sNewName); ?> <h3>Print_r</h3> <?php print_r($sOldName); print_r($sNewName); ?> </body> </html>
© 20072024 XoaX.net LLC. All rights reserved.