First thing first to test php code, Create a file called hello.php and put it in your web server’s root directory (DOCUMENT_ROOT) with the following content in it:
Example: hello.php
<html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html>
Now you can access this file in your browser with your web server’s URL, ending with the /hello.php file reference. If you are working on your local server then the URL must be like these:
http://localhost/hello.php or http://127.0.0.1/hello.php
This program is simple and it does is display: Hello World using the PHP echo statement. If you do inspect element from your browser settings to check your test PHP code, you will find this HTML code in the browser for your page:
HTML view in browser
<html> <head> <title>PHP Test</title> </head> <body> <p>Hello World</p> </body> </html>
You can check their official website here. To get an introduction to the PHP, check this link here.