Question: What is PHP, and what does it do?
-PHP stands for PHP: Hypertext Preprocessor. Now that may seem a bit confusing, but let me explain. PHP is this thing that makes websites do things. For example, this forum! It's all done in PHP. (excluding all the CSS and HTML) It's like the insides of a car.
----------------------------------------------------------------------
Lesson 1: Echoing Statements
Before you read this, I recommend learning basic HTML. Because I will be using some of it.
Open a text program like notepad or (as I will be using) ConText. And write this script:
[lua]
<html>
<title>Hello World!</title>
<?php
//echoing hello world
echo ("Hello World!");
?>
</html>
[/lua]
As you can see, I added the php tag which is <?php?> NOTE: Always use these tags around your code because it's what tell the site to run it.
Also, end every PHP line with a ';'. It also tells the page to run it.
As you can see again, the statement 'echo' or 'print' (alt) is used to show that we are printing the sentence 'Hello World!'. Also, I use something called a comment in there by using //(content here) it is very VERY useful and neat looking to add comments. Plus it lets the reader understand the code.
NOTE: I also space out my code. That's very useful for the reader and YOU if you finding out some kind of error you made.
Lesson 2: Variables
A variable in PHP is a stored figure in the code, then can be mentioned later in code ex: echoed out (which is what we will be doing)
Write this in your text program and I will explain it after:
(I'm not integrating HTML in this file for space sake, but it is recommended for website posting.)
[lua]
<?php
$text = 'Hello World!';
echo $text;
?>
[/lua]
As you can see, this echos the variable $text. Variables ALWAYS start with $. Also, $text-2 is not allowed. $text_2 is. No - allowed or spaces. Also, they cannot start with numbers.
TIPS: When writing variables stick to lower case letters. It's easy to remember and to use.
Lesson 3: Strings
Coming soon
-PHP stands for PHP: Hypertext Preprocessor. Now that may seem a bit confusing, but let me explain. PHP is this thing that makes websites do things. For example, this forum! It's all done in PHP. (excluding all the CSS and HTML) It's like the insides of a car.
----------------------------------------------------------------------
Lesson 1: Echoing Statements
Before you read this, I recommend learning basic HTML. Because I will be using some of it.
Open a text program like notepad or (as I will be using) ConText. And write this script:
[lua]
<html>
<title>Hello World!</title>
<?php
//echoing hello world
echo ("Hello World!");
?>
</html>
[/lua]
As you can see, I added the php tag which is <?php?> NOTE: Always use these tags around your code because it's what tell the site to run it.
Also, end every PHP line with a ';'. It also tells the page to run it.
As you can see again, the statement 'echo' or 'print' (alt) is used to show that we are printing the sentence 'Hello World!'. Also, I use something called a comment in there by using //(content here) it is very VERY useful and neat looking to add comments. Plus it lets the reader understand the code.
NOTE: I also space out my code. That's very useful for the reader and YOU if you finding out some kind of error you made.
Lesson 2: Variables
A variable in PHP is a stored figure in the code, then can be mentioned later in code ex: echoed out (which is what we will be doing)
Write this in your text program and I will explain it after:
(I'm not integrating HTML in this file for space sake, but it is recommended for website posting.)
[lua]
<?php
$text = 'Hello World!';
echo $text;
?>
[/lua]
As you can see, this echos the variable $text. Variables ALWAYS start with $. Also, $text-2 is not allowed. $text_2 is. No - allowed or spaces. Also, they cannot start with numbers.
TIPS: When writing variables stick to lower case letters. It's easy to remember and to use.
Lesson 3: Strings
Coming soon