I've been started studying PHP in my spare time, and the first code example I was given was this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>
From what I understand, this should write out "Hello World". However, all I see is a blank webpage. Any ideas why this is and how I should go about fixing it?
echo command in linux is used to display line of text/string that are passed as an argument . This is a built in command that is mostly used in shell scripts and batch files to output status text to the screen or a file.
Although not necessary, it is a good programming practice to enclose the arguments passed to echo in double or single quotes. When using single quotes '' the literal value of each character enclosed within the quotes will be preserved.
As explained in this comment on that answer you link to, echo $0 simply shows you the name of the currently running process: $0 is the name of the running process. If you use it inside of a shell then it will return the name of the shell. If you use it inside of a script, it will be the name of the script.
The echo command ends with a line break by default. To suppress this, you can set the control character \c at the end of the respective output.
Here's a checklist
As a test try saving this as info.php
<?php
phpinfo();
?>
and see if it displays information about your server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With