Starting PHP script!
We know that your are eager to start learning php. We will not taking this too long so follow the steps below.
Okay! after installing your localserver now it’s time to run your first PHP script.
Reminder: When writing a php script always start with <?php and end with ?>
example: <?php // your script ?>
Follow this steps
1. Open your favorite text editor. on me I’m using sublime and write the following code.
<?php echo 'Hello World'; ?>
2. Create a directory inside your htdocs name it as “myphp” and save your file as “index.php”.
3. Browse to your browser localhost/myphp if you see hello world then you make it write.
I’m using localhost:8080/myphp because I change my port to 8080.
echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses.
In short echo is use to output a result.