I am trying to start programming in PHP. I found this example "Hello, World" PHP page.
Here is the code:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
However, instead of displaying:
Hello World
It displays:
Hello World
'; ?>
Viewing the source shows
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
instead of
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>
So it looks like it did not get parsed by Chrome. What is causing this problem?
$string = 'Hello World! <br>'; // You can echo the variable, similar to the way you would echo a string. echo $string; // You could also use print. print $string; // Or, if you are familiar with C, printf can be used too.
Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the PHP. Step 2: Now, we have to place the cursor in any tag of the <body> tag where we want to add the code of PHP. And, then we have to type the start and end tag of PHP.
Make sure the file is named .php and not .html or .htm. Also make sure you have uploaded it to a PHP web server.
Chrome (or any browser) does not parse PHP at all... the server parses the PHP and passes the HTML to the browser. Bottom line, the browser should never know PHP exists.
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