• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Nikkster's PHP Lesson Part 1, intro & basics

Nikkster

Programmer
Joined
May 9, 2008
Messages
2,848
Reaction score
9
Location
Confidential
Hi there and welcome to my tutorial. This course will focus on the programming language 'PHP' which stands for "Hypertext Preprocessor". I assume you have seen me making C lessons before.

Why?
After some reading in the web application forum, I found that quite many does not have a clue of what they are doing.

FAQ:
Do I need any preknowledge?
Basic knowledge about HTML/CSS and javascript, should do it. Although, it is not necessary.
I already know C/C++, will it be easier for me to learn PHP?
If you know C, you know PHP. Having a quick look at PHP's structure might be a good idea, though.

INTRO
PHP is used to create dynamical content on the website and communicate with a database, (MySQL).

CREATING YOUR FIRST PHP CODE
First you will need a webserver. I recommend XAMPP (LAMPP). If you have IIS, it works also.
Now, create a new file with the extension .php. We'll call it "example.php". Open up the file with a texteditor, I recommend "notepad ++" or "Aptana Studio".

PHP:
<?php
$variable = 'Hello World';

echo $variable;
?>

What we're doing here is, we always start our codes with either <? or <?php (depending on PHP version) and finish the code with ?>. Then, we write a simple variable and defines it. Then we echo or "print" the text inside the variable on the webpage. You can also do it in other ways, of course.

PHP:
<?php
echo 'Hello World';
?>
To see the results of our new code, start the webserver and go to localhost/example.php. The text "Hello World" should appear on the white background in a black text.

COMMENTS
As in all other programming languages, it works to create comments in PHP, which can be good if you are working on big projects.
Creating comments in PHP is as simple as writing // this is a PHP comment.

Example:
PHP:
// this is a comment in PHP

If you have any questions, please post in this thread. Also, post what you think about this tutorial. In the next tutorial, we'll be going for more in-depth about PHP. Although, I will try to go through the most basics first, and then we can go for sessions, cookies, $_POST, if-statements, $_GET, etc.

We will also be discussing security "mysql_real_escape_string". We will talk more about this later.
 
Awesome.
If you can explain me how to make an AAC or something relevant, it would be nice =)
 
As far as I know that has to do with an option: short_open_tag.

Which has something to do with the PHP versions, no? As far as I know, this was changed in the latest PHP versions. Nothing is being said that it has nothing to do with the short_open_tag option in PHP.

However, back on topic.. like I mentioned, a new tutorial will be written tomorrow. If you have any questions, I would love to have them answered for you. Just let me know.


EDIT: 02/09/2010 10:08
A new tutorial is out: http://otland.net/f481/nikksters-php-lesson-part-2-variables-operators-mysql-99902/
 
Last edited:
I strongly recommend people to avoid short tags, unless for private projects (because then it is completely up to each individual). The reason I say this is due to the simple fact that not everyone has short tags enabled (has nothing to do with the PHP version you are running (unless earlier than the version they were released in - obviously)) and would result in their applications to fail.

What you could also add to the tutorial is a bit more in-depth explanations, e.g. why you are using double/single quotations and why there's a semi-colon at the end of the line. All of these things may seem every day usage to you, but I guarantee you that there is plenty of folks out there having absolutely no idea what they do.

Despite the size and lack of in-depth explanations I really do appreciate the fact that you sat down and wrote this tutorial. I would love it if more users would get into PHP!
 
Back
Top