Page 511 - Computer_Science_F5
P. 511
Computer Science (iii) You can also display the value of a variable using the echo statement.
For example: $name = “John”; echo $name;
(iv) Multiple values can be concatenated within the echo statement using
the period (.) operator. For example: echo “Hello, “. $name;
(v) The echo statement does not require enclosing parentheses.
FOR ONLINE READING ONLY
An example that combines these concepts is shown in Program Example 8.1:
Program Example 8.1:
PHP program to demonstrate echo statement
php
<button><svg><path></path></svg><span>Copy code</span><span></span></button>
<?php
// This is a single-line comment
/*This is a multi-line comment */
$name = “John”; // Assigning a value to the $name variable
$age = 25; // Assigning a value to the $age variable
echo “Hello, World!”; // Outputting a string literal
echo “My name is “. $name . “.”; // Concatenating a string with a variable
echo “I am “. $age . “ years old.”; // Outputting variables with text
?>
Output:
Hello, World!
My name is John.
I am 25 years old.
Understanding PHP syntax, commenting, variables, and echo statements is crucial
as you progress with PHP programming in connection with database management.
The concept of server-side scripting in the web development
Server-side scripting is a web server technology in which a user’s request is fulfilled
by running a script directly on the web server to generate dynamic web pages. It
is a key component of web development that enables the creation of customized
responses for each user request. Unlike client-side scripting where scripts are
executed by the browser, in server-side scripting, the script is executed on the server
and the client only sees the resulting HTML.
502
for Advanced Secondary Schools
Computer Science Form 5.indd 502 23/07/2024 12:35

