School of Computing. Dublin City University.
Online coding site: Ancient Brain
coders JavaScript worlds
Server-side code.
Normally in public_html
Normally named like:
file.php
File contains normal HTML, and PHP code mixed in, delimited as follows:
<html> <body> html code <?php php code ?> more html code
$x = 3;
print "x is $x";
and then error messages are displayed.ini_set ( 'display_errors', true ); ini_set ( 'display_startup_errors', true ); error_reporting ( E_ALL );
nonExistentFunction();View it with and without those 3 lines above inserted.
print "x is $x";
var_dump($x); print_r($x);
Strings in PHP shows ways of doing a multi-line string:
$var = " text text ";
Advantages: Simple syntax.
Disadvantages: All double quotes in the text must be changed to single quotes or else "escaped".
Can't just dump HTML in here.
$var = <<<MULTILINE_DELIMITER text text MULTILINE_DELIMITER;
Advantages: Can have single and double quotes in the text unchanged.
Can just dump HTML in here.
Disadvantages: Complex syntax.