Tyler
09-29-2006, 04:25 AM
This is the first Tutorial for PHP then will cover text and varibles.
First off Text.
<?PHP
echo("Hello World");
?>
Look now you made text when it comes up in a browser.
now Variables.
<?PHP
$test = "echo"
echo("$test");
?>
You just made a Variables.
Next Time we will learn about Functions and Arrays.
SBJ95
11-25-2006, 08:20 PM
You should use a little more detail when explaining things, so you know when to use them and why they work...
Virtual Headache
11-26-2006, 01:18 AM
Well, he's right, this tutorial isn't detailed enough for newbies.
You also should mention that you need to have PHP installed on your own computer so you can actually see it as well as the file needs to have the extension ".php." to work properly.
<?PHP
$test = "echo"
echo("$test");
?>
You forgot a ; at the end of the 2nd line.
Electron
11-27-2006, 09:12 AM
I agree with the two previous posters, and would like to add that you forgot to mention some pretty important things that are crucial knowledge for people trying to learn PHP.
You should say that PHP is a server-side scripting language, that it is an interpreted language, so you have to have PHP installed on the machine where you want to execute the code, and the server program must be configured to handle the request. Otherwise, there will be no processing. All PHP code blocks begin with an opening <?php and a closing ?> tag.
Readers should know that in PHP, all variables begin with a dollar ($) sign. To create a new variable, just write a dollar sign followed by the name you want to assign to the variable. For example,
$my_variable = 1;
will create a new variable with the value of 1, that can be used later in the script. Variable names must not start with a number, though they may contain one (such as $my2cents), they may contain only upper and lowercase Latin alphabet letters and underscores. It's important to note that in PHP all statements have to end in semicolons(;).
Next, it's important to note that in PHP there are two basic ways of creating a string. Firstly using the single-quote sign (') a.k.a. an apostrophe, and the double-quote sign ("). There is a difference between the two. This is best shown in an example. (To undestand the example, you have to know that the echo() function is used for printing stuff out onto the screen)
<?php
$text = 'Lol! HAHAHA';
$variable_1 = 'This is a piece of $text';
$variable_2 = "This is a piece of $text";
echo $variable_1;
echo $variable_2;
?>
This block will print out two different things. Firstly, the variable called $variable_1, which will print this out:
This is a piece of $text
And $variable_2, which will print:
This is a piece of Lol! HAHAHA
As you can see, if you use single quotes, any variable names in the string of characters will be ignored, the $text is printed out as it is, "$text", whereas if you use a double-quoted string, any variable names in the string will be replaced with their values. Therefore, $text becomes 'Lol! HAHAHA'.
...
^ Something along these lines. If you want your tutorial to be useful, you have to put more detail in it. You plan to jump straight to arrays and functions, well what about first saying something about the basics of PHP, comments, more about echo(), why it's one of the rare functions that don't need parentheses to be called, etc.
Your tutorial "assumes" a lot of things. It might be enough for people who have a degree in computer science and already know a lot of different programming languages, but for your intended audience, this is too "to the point" and I doubt any beginners will understand much.
Not to sound harsh, but I also think it would be a good idea if you get to know PHP a bit better yourself before trying to transfer your knowledge it to other people. Otherwise, you may make errors which will confuse people.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.