Now, after we learned how to show content and also had a first glance at variables, we will now go a step further.
To define a variable in PHP you just need to use $ and a variable name:
You can use as variable name whatever you like, however you are not allowed to let it start with a number, like
$1variable and there are also some predefined variables, about which I will talk later.
There are many types of variables, but for now we concentrate on 4 types (actually 5, but the fifth will follow in another tutorial). Weiterlesen
So, here it is, my first tutorial ever!
I will try to explain how to create your first PHP “script”.
Requirements for the PHP Tutorials:
- at least good knowledge about HTML
- Webspace or local server with PHP Support
- Additional: knowledge about CSS
Well, let’s start with the script itself, I will explain everything later:
echo "Hello World!<br />";
print 'Hello World!<br />';
echo "<a href=\"http://www.ruelicke.net\">Hello World link</a><br />";
print '<a href="http://www.ruelicke.net">Hello World link</a>';
Create a HTML file, insert the code above into the <body> and save it. Then rename the HTML file from foo.html to foo.php
Upload the file and access it.
If everything is working, then you should see “Hello World” (without the quotes) 4 times. Congratulations, looks like you just wrote your first PHP script.