Php:lesson #1 - The basics of PHP.

free web hosting
Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > PHP

Php:lesson #1 - The basics of PHP.

Archimedes
First off, we need to meet each other. I am Archimedes! xD I chose this name because I have a joy for mathematics and calculators and such. Archimedes is the man who discovered Pi(3.14159).

Things you should know before we start Lesson #1.
1.HTML
2.General scripting knowledge or what it actually does.

Alright, to the PHP lessons.

1.PHP stands for PHP; Hypertext Preprocessor.
2.PHP is used all around the world to build dynamic web pages and web sites.

Basic Syntax
1. All PHP scripts start with the<?php or <? tag. I'd use the <?php tag just to be a little bit more tidy, just my opinion though.

2. To write something in PHP, we use the 'echo' or 'print' statement, like so.
CODE
<?php
echo "Hello Astahost!";
?>

Output: Hello Astahost!

3. All PHP statements end with a semicolon(wink.gif.(In italics in the first code snippet.)

Comments
4. To type comments in PHP we use // for one line comments or /* */ to make a comment block, like in this example. Comments DO NOT end with a semicolon.
CODE
<?php
//This is a one lined comment(has no effect on the script, whatsoever)
echo "Hello Astahost!";
/*
This
is a
Comment block(has no effect on the script, whatsoever)
*/
?>

Output: Hello Astahost!

Variables
5. At school, you use variables to substitute for numbers. Like, 4f + f = d. f=2, therefore 4*2+2=10. d=10.
6. In PHP, variables are 'saved' with the USD sign($).
CODE
<?php
$text = "Hello";
$number = 4;
echo $text;
?>

Output: Hello

8. To type 2 variables after each other, you'd separate them with '. " " .', like so.
CODE
<?php
$text = "Hello";
$number = 4;
echo $text . " " . $number;
?>

Output: Hello 4

Operators

Operator - Name - Ex. - Output
+ - Addition - x=2. 4 + x - 6
- - Subtraction - x=2. 4 - x - 2
* - Multiplication - x=2. 4 * x - 8
/ - Division - x=2. 4 / x - 2
For a list of all operators, click here.



That's it for our first lesson, see ya soon!


The Human Calculator,

Archimedes

 

 

 


Reply

yordan
Nice tuto, thanks.
Just a stupid question. You say "PHP stands for PHP; Hypertext Preprocessor."
How do you make php with Hypertext Preprocessor ? It should sound more like hpp ?

Reply

FirefoxRocks
QUOTE(yordan @ Jul 28 2008, 07:55 AM) *
Just a stupid question. You say "PHP stands for PHP; Hypertext Preprocessor."
How do you make php with Hypertext Preprocessor ? It should sound more like hpp ?

PHP = PHP: Hypertext Preprocessor

http://en.wikipedia.org/wiki/Recursive_acronym

Reply

yordan
QUOTE(FirefoxRocks @ Jul 28 2008, 09:02 PM) *
PHP = PHP: Hypertext Preprocessor

http://en.wikipedia.org/wiki/Recursive_acronym

Now I see :
QUOTE
PHP — PHP: Hypertext Preprocessor (originally "Personal Home Page" tools, officially changed for PHP 3

"Personnal Home Pages" is understandable for PHP, it's a nice historical explanation.

Reply

ozgur
biggrin.gif

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Recent Queries:-
  1. php lesson school - 123.71 hr back. (2)
Similar Topics

Keywords : php, lesson, 1, basics, php,

  1. Php: Lesson #3;functions
    PHP. (0)
  2. Php: Lesson #2; If...else Statements.
    Basics of If...Else statements. (1)
    Alright, this is part #2 of my PHP Lessons. We will go into depth with more of the, scripting part
    of PHP. Things you should know. 1. Basic PHP 2. Understanding of scripting. If...Else statements
    1. If...Else statements are used if you want your script/scripts to do something based on a
    variable. CODE if (condition) code to be done if condition is true; else code to be done if
    condition is false; ?> 2. With that, you're probably a bit still confused as to what it's
    doing, I was too at first. Look at the next code for a better explanation. This is if t....
  3. Lesson Of The Day
    daily lessons of life, love and all that inbetween (5)
    I have been learning many things through out my life, whether I wanted to learn the lesson or not.
    Well today I'm want to tell you about what I learned about drinking. I'm sure at this point
    your think WFT is he talking about what can you learn from that. You see in my case I never drank
    so when I first did I didn't have anyone to tell me the do's and don't of drinking. So
    today I will share with you what I learned and I learned it the hard way. First of I'll tell
    you the story of how I arrived to this lesson. I had just arrived at my firs....
  4. Network Outage. Distribution Switch Ddosed.
    Lesson Learnt (5)
    The Distribution Switch to which our network is connected was DDOSed causing a partial network
    failure. The entire downtime was reduced due to our DNS shift in Dec 2007. We regret to inform that
    today at about 11 AM IST, We started experiencing a network lag. By 12.30 PM IST, the network was
    down partially with most of our servers affected except Zeta and Mu. By 1.00 PM IST, the entire
    network had gone down and was recovered slowly by 2.00 PM IST. By 2:30 IST, the network was
    completely recovered and all servers were operating smoothly. FULL STORY: http://www.x....
  5. Php Tutorial #1
    Starting off with the basics. (0)
    Many people have helped me in learning php, heck if it weren't for a certain someone(not on this
    site, on legacy-game.net) then i would'nt even be here seeing or posting any of this. Just a
    couple of things to be kept in mind, commands/statements we are learning are going to be in bold :
    CODE echo "..."; ?> and extra stuff will be in italics and will be explained in detail ------
    Now to get started with php, you would need a webhost if you want to directly do things online,
    otherwise download a localhost server: -Apache -Php -MySQL You have to get a sepe....
  6. Learning Php/sql Basics
    Want to learn CSS, PHP and create a website (17)
    Hello, I've been wanting to learn to create websites for a long time. I'm not sure how hard
    it will be and how long it will take to learn enough to make my own database-driven website. I
    studied SQL, basic programming, worked with databases and am familiar with HTML tags, but this all
    was for work, university and I never paid a lot of attention to details. In the past few days I read
    beginner's tutorials on PHP/SQL, CSS and even HTML. Now I want to create a simple database with
    some tables to practice with PHP scripts for a website, write and read database i....
  7. C# Tutorial : Lesson 9 - Constructors & Destructors
    (0)
    The need for Initialization A class contains data members (variables) and member
    functions. Initializing the values of these data members is essential, at times. Take a look at the
    following scenarios:- CODE int MyNumber; Console.WriteLine("My Number = {0}", MyNumber);
    This block of code declares a variable MyNumber and then prints it on the screen. However, when
    you try to execute these instructions, an error Use of unassigned local variable 'Product'
    will be generated. This is because, we are trying to use the value of MyNumber , even be....
  8. C# Tutorial : Lesson 8 - Functions/methods
    (0)
    The programming model has gone through many refinements, each change improving upon the model. One
    of the early changes was the inclusion of Subroutines or Subprograms. As the names suggest, these
    are fragments of code within a program. They offer the following advantages:- Reduction of code
    duplication by offering re-usability Simplifying program logic by decomposing the program into
    smaller blocks Improving readability of the program Why do we need functions?
    Consider the following program:- CODE using System; namespace ConsoleApplication1 { ....
  9. Does Anyone Know Rpg Maker 2003
    There are a lot of basics that i need to learn (3)
    For weeks now i've been searching the net looking for help on rpg maker 2k3 and wherever i go
    I'm treated with hostility for being a newb. So now I'm looking for some genuine help. As a
    newb I've been reading and reading trying to find out how to use the functions, below I'll
    leave a list of things i can't figure out. 1. Switches *Probably the most important thing
    in the game but I can't figure out how to turn them on and off. 2.a password thing 3. More
    sprites if available Now I would prefer if the answers they could be short and sweet.....
  10. Basics Of Php For Beginners - Suggestion
    Help Needed For Project (5)
    Hi all, I have a friend who, for his extended IT project is interested in making a website partly
    out of php. When he asked for advice my first thought was here. I would like to know some good
    websites, tutorials etc that he can use to introduce himself to php (he hasn't done much
    before). He is interested in making a simple login/subscription service where you can signup and
    then login to a 'members only' page. Any ideas and code samples that you have to share would
    be greatly appreciated. /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" a....
  11. C# Tutorial : Lesson 7 - Creating Value Types & Reference Types - Part II
    (1)
    foreach statement This statement is explicitly used to traverse through arrays. The
    benefit of using foreach over the normal for statement is that it is not needed to check the
    size of the array while using the former. Syntax:- foreach(type identifier in expression) {
    statement 1; statement 2; .... } Suppose we have an array StudentNames containing the name of all
    the students in a class. We need to display the name of each one of them on screen. First we will
    see how it can be done using the for loop. CODE string StudentNames = new string {"....
  12. C# Tutorial : Lesson 6 - Creating Value Types & Reference Types - Part I
    (0)
    Value Types & Reference Types In C#, Variables are either value types or reference types
    depending on what they store, values or references. By reference we imply that the variable holds
    the memory address of another location where the actual value is stored. All built in data types -
    Int, Char, String, Float, Boolean, etc are value types while classes are reference types. The
    following is a diagrammatic representation of these two types. In this picture there are two
    variables Num1 and Num2. Both of these being integer variables store the values directly.....
  13. C# Tutorial : Lesson 5 - Encapsulation & Abstraction
    (0)
    Encapsulation & Abstraction Two concepts that go together in the object oriented approach
    are Encapsulation & Abstraction. Abstraction is the representation of only the essential features of
    an object, while Encapsulation is the hiding of the non-essential features. Think of a person
    driving a car. He does not need to know the internal working of the engine or the way gear changes
    work, to be able to drive the car (Encapsulation). Instead, he needs to know things such as how much
    turning the steering wheel needs, etc (Abstraction). Consider the example from ....
  14. C# Tutorial : Lesson 4 - Object Oriented Programming
    (2)
    Object Oriented Programming Object Oriented Programming is a methodology modeled on real
    life. It comprises of the basic unit, an object, being used in implementing a program. Think of all
    the objects around you - cars, buses, birds, trees, etc. You will find countless ones of them,
    everywhere you go. In order to tackle this huge number, we started classifying them, thus came the
    term Class. Class A class is a composition of the theoretic characteristics (attributes and
    properties) of an object and the things it can do - behaviors, methods and features. Tak....
  15. C# Tutorial : Lesson 3 - Programming Constructs
    (1)
    Conditional Branching By branching we imply, having different paths for execution.
    Conditions are used to determine which statements need to be executed. Suppose, you have a program
    to store the details of employees. Depending upon the post of the employee, there would be various
    fields associated with it. A department head, for example, would have a property denoting the
    department he heads, etc. We use conditional branching in such a scenario. C# provides the
    following conditional constructs:- if .. else Syntax:- if ( ) { statements } else { statement....
  16. C# Tutorial : Lesson 2 - Variables & Operators
    (0)
    Variables A Variable is a named location that stores a value. Although variables are
    physically stored in the RAM, their actual memory address is not known to the programmer. We can use
    the variables via the name we give them. These are the rules for naming a variable:- The name must
    begin with a letter or an underscore & can be followed by a sequence of letters (A-Z), digits (0-9)
    or underscore (_) Special Characters such as ? - + * / \ ! @ # $ % ^ ( ) { } , ; : . cannot be
    used in the variable name. A variable name must not be the same as a reserved k....
  17. C# Tutorial : Lesson 1 - Hello World Program
    (0)
    This is the first installment of my venture to explain the bits and pieces of C# that I have managed
    to learn at NIIT. In this lesson we would be creating the Hello World application. STEP 1 : Create
    a New Console Application in Visual C# The IDE automatically adds the following code:- CODE
    using System; using System.Collections.Generic; using System.Text; namespace HelloWorld {
        class Program     {         static void Main(string args)         {         }     } } Lets
    take a look at the first 3 lines. All of these lines begin with the keyword using....
  18. Programming In Glut (lesson 6)
    Texture filters and lighting (1)
    This tutorial demonstrates how to use texture filters and will let you see the differences of each
    filter. I will also be introducing lighting into this tutorial. We first have to create our
    "bitmap.h" header file with the functions we use to load our bitmaps, this is changed from the last
    tutorial to fit the needs of this one. The first thing to do is to link all of our OpenGL libraries
    and include our needed headers for the functions we will call. CODE #pragma comment(lib,
    "opengl32.lib")//Link to the OpenGL libraries #pragma comment(lib, "glu32.lib") #pragma....
  19. Programming In Glut (lesson 5)
    How to texture map and use keyboard controls. (0)
    In this tutorial I am going to teach you how to texture map your polygons and implement basic
    keyboard control. There is alot of new material in this tutorial and I hope I have explained it
    enough. Before you get started you will want to name a bmp file "image.bmp" or "image" depending on
    your computer settings (if one doesn't work then use the other) and place it in the same folder
    as your project. Now to start we will be making a seperate header file where we will write our
    function to load a bitmap file. You should name it "bmpload.h". The code to write in it ....
  20. Programming In Glut (lesson 4)
    Making 3D objects (7)
    Hello, in this tutorial we will be creating a 3D pyramid. We are building this tutorial from Lesson
    3, but I took out the 2D objects and placed a 3D pyramid in there instead. The 3rd axis for drawing
    can be a litle confusing, but after you get the hand of it you'll do fine. Now when you are
    setting a 3D vertex just remember that the camera is on the positive end of the z axis. So things
    that have a more positive z axis value are closer than verteces with a more negative value. Well
    let's get started We always start by including the glut library CODE #i....
  21. Programming In Glut (lesson 3)
    How to animate objects in GLUT (1)
    In this tutorial I am going to talk about how to get animation in your program. I will be working
    directly off of Lesson 2 and will now take out the notes left behind from Lesson 1, but I will leave
    the notes from Lesson 2. CODE #include //include our glut library First we are going to
    initialize a variable called "time" which will record how much time has passed so we can use it to
    determine how to animate the objects. Then we have our init function that initializes some stuff in
    GLUT CODE float time = 0;//(NEW) variable to record the how much time has....
  22. Programming In Glut (lesson 2)
    Learn how to draw 2D polygons in this tutorial (8)
    This is the second lesson in my series of tutorials on how to use GLUT to create graphics. In this
    tutorial I am going to be teaching you how to create different types of polygons. I am going to be
    adding on to last tutorial's code and will leave the notes in to help you remember what all the
    function are. I will also be noting the new functions that we will be using and how to use them.
    CODE #include //Include the GLUT functions This time we are going to not only set the
    background color, but set the area that we are viewing as well. gluOrtho2D(); sets....
  23. Programming In Glut (lesson 1)
    The first of a series of tutorials on how to use the OpenGL Utility To (3)
    Hello, I'm starting a series on how to program in OpenGL using the OpenGL Utility Toolkit,
    a.k.a. GLUT. I chose GLUT because it is quick and easy to write, and very easy to learn. In this
    tutorial I am going to teach you how to create a basic window which we will build off of in later
    tutorials. Throughout the tutorial I will leave notes to let you know what each command does, and
    how you can modify it to fit your needs. Everything in the code section can be copied and pasted
    into your compiler and it should compile proporly, if it does not, please let me know, a....
  24. The Basics Of Google Adsense
    (2)
    hi dears if you want to know what is google adsense go on read this articleh QUOTE The Basics
    On How TO Start Making Money With Adsense Adsense is considered as one of the most powerful tool
    in a website publisher’s arsenal. It enables a person to monetize their sites easily. If used
    properly, it can generate a very large and healthy income for them. However if you are not using
    them rightly and just maximizing the income you squeeze from it, you are actually leaving a lot of
    money on the table. Something all people hate doing. How you can start earning money ....
  25. [tutorial] Basics Of C Programming - Part 2
    (21)
    Ok, well here is the Second part of the tutorial i promised. Operators & Expressions in C
    Introduction In c the variable, arrays or
    function references are combined with operators to form expressions.
    Eg. C=A+B The data items that the operators act upon are
    called operands. Some operators require two operands will others
    require just a single operand to act upon. Types Of Operators : ....
  26. [tutorial] Basics Of C Programming - Part 1
    (11)
    Well, I was going through a few posts on C / C++ on asta .. and found a very less C related
    subjects. I went through the entire tutorial of mastercomputers >>HERE .. It was a nice
    tutorial for guys who have a little knowledge of programming basics and want to go into hardcore
    programming. Since there was no Basic overview of what C was, i thought of writing one /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />. I wil make shure that what i
    write will be 100% accurate, but its human to error so please correct me if i am wrong. Let....
  27. Lesson #2 - Switch Statement In C#
    Using the Switch Statement in C# (1)
    In the previous lesson we demonstrated did a basic input output application which asked your your
    name and replied with a general greeting using the name you entered. In this lesson we are going
    to learn about a conditional statement called the switch statement. Usually if and if else
    statements are taught before switch statements. Although these are very useful, I find the switch
    to be easier and more fun to use. The program written below is very similar to the previous
    program where the user is asked to enter their name, however now the program will loo....
  28. Lesson #1 - Introduction To C#
    Console Application (1)
    This tutorial will help get you started with C# Sharp. These tutorials will assume that you are
    using the Visual Studio environment. If you are just curious to test out some code, then you can
    copy and paste this code into your CS file, however, before doing so, make sure to name your project
    the same as the namespace on the code. But since this first program is fairly easy, it will not
    hurt to type it out. It is fairly easy and short. Also, this program is highly commented so it
    should be easy to follow along. Comments will have 2 forward slashes before them '....
  29. The Very Basics Of Animation
    (8)
    Welcome, Many people feel they want to learn animation and want to do those animated effects. Most
    people think animation is very hard, but the fact is it isn’t at all. I thought that if I created a
    tutorial it would help people ion this situation to understand these basics of animation and how
    easy it really is once you spend some time with the piece of software you use whether it’s
    Macromedia MX Flash or something else, I use ImageReady, part of Adobe Photoshop and is very useful
    for animating. I wrote this tutorial for beginners wanting to learn the basics of Animati....
  30. Switching Forms - VB.NET
    Some VB.NET Basics (2)
    When I started coding in VB.NET I was unsure of how to switch forms at a click of a button or any
    other event. So for anyone with the same problem this is for them. First you must have at least two
    forms in the project. If you do not know how to add forms to a project heres how: 1) Under the
    "Project" Menu select "Add Windows Form..." 2) In the dialog box that pops up near the bottom you
    will see "Name:" with a textbox beside it. In the text box type the name of the new form. For this
    example we will just use the default name, "Form2.vb" 3) Click "Open" You now have....

    1. Looking for php, lesson, 1, basics, php,






*SIMILAR VIDEOS*
Searching Video's for php, lesson, 1, basics, php,
Similar
Php: Lesson #3;functions - PHP.
Php: Lesson #2; If...else Statements. - Basics of If...Else statements.
Lesson Of The Day - daily lessons of life, love and all that inbetween
Network Outage. Distribution Switch Ddosed. - Lesson Learnt
Php Tutorial #1 - Starting off with the basics.
Learning Php/sql Basics - Want to learn CSS, PHP and create a website
C# Tutorial : Lesson 9 - Constructors & Destructors
C# Tutorial : Lesson 8 - Functions/methods
Does Anyone Know Rpg Maker 2003 - There are a lot of basics that i need to learn
Basics Of Php For Beginners - Suggestion - Help Needed For Project
C# Tutorial : Lesson 7 - Creating Value Types & Reference Types - Part II
C# Tutorial : Lesson 6 - Creating Value Types & Reference Types - Part I
C# Tutorial : Lesson 5 - Encapsulation & Abstraction
C# Tutorial : Lesson 4 - Object Oriented Programming
C# Tutorial : Lesson 3 - Programming Constructs
C# Tutorial : Lesson 2 - Variables & Operators
C# Tutorial : Lesson 1 - Hello World Program
Programming In Glut (lesson 6) - Texture filters and lighting
Programming In Glut (lesson 5) - How to texture map and use keyboard controls.
Programming In Glut (lesson 4) - Making 3D objects
Programming In Glut (lesson 3) - How to animate objects in GLUT
Programming In Glut (lesson 2) - Learn how to draw 2D polygons in this tutorial
Programming In Glut (lesson 1) - The first of a series of tutorials on how to use the OpenGL Utility To
The Basics Of Google Adsense
[tutorial] Basics Of C Programming - Part 2
[tutorial] Basics Of C Programming - Part 1
Lesson #2 - Switch Statement In C# - Using the Switch Statement in C#
Lesson #1 - Introduction To C# - Console Application
The Very Basics Of Animation
Switching Forms - VB.NET - Some VB.NET Basics
advertisement




Php:lesson #1 - The basics of PHP.