Now that you know what PHP is and what it can do for you, it’s time to develop your first Hello World programme with it!
First and foremost, PHP must be installed on your local PC. Installing a XAMP (Cross-Platform, Apache, MySQL, and PHP) or WAMP (Windows, Apache, MySQL, and PHP) server will do this.
XAMP is compatible with all operating systems, but WAMP is only compatible with Windows. WAMP is what I’ll be utilising.
Check that all WAMP or XAMP server services are up and functioning. If you’re running WAMP, the WAMP logo should appear green on your taskbar.
You may also save your “Hello World” text in a variable and then show it using the echo system in the browser.
The dollar symbol ($) is used to declare variables in PHP. A semi-colon must also be used to end your assertions, except the last one.
echo $greeting = “Hello World” $greeting
To run your code in the browser, open it and type localhost/the-folder-of-your-PHP-file/php-file.php into the address bar, then enter.
If your WAMP or XAMP server isn’t up and running, it won’t work.
Because I got the file location correct, you can see that the code ran correctly in the browser.
In web development, PHP is still a useful and widely used language. Despite the ridicule and debate over whether it is still valuable, PHP developers continue to make a good living using the language. PHP does not appear to be going away anytime soon.