Basic Php Tutorial

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Basic Php Tutorial

ghostrider
Hypertext Preprocessor, or PHP for short, is a dynamic language, meaning that unlike HTML, PHP can change itself without you having to update the page using FTP or the CPanel. PHP has endless possibilites, you can use MySQL (a database program) with it, create polls, counters, work with images, process forms and CGI, and even send email. In order for you to start PHP coding, you need to tell the server that is processing your webpage that this is PHP. You can do that 3 seperate ways.

CODE
<script LANGUAGE="PHP">

CODE
<?PHP

CODE
<?


After you have done that, you can start writing in PHP. The first function that you will learn is echo().
Echo() will output a string of text that you specify. Here is an example:
CODE
<?PHP
echo("Hello World!");
PHP?>


Each line of code in PHP ends with a semicolon (wink.gif. This is very important, if you don't do this, your program will crash with a fatal error.

Another way you can do the same thing is like this:
CODE
<?PHP
$thisisavariable = "Hello World!";
echo("$thisisavariable");
PHP?>


$thisisavariable is a variable. All variables have a dollar sign ($) before them. Variables can also contain numbers, as shown below.
CODE
<?PHP
$var = 123;
PHP?>


Comments can be shown in PHP also, they are placed after semicolons and have "//" before them.
CODE
<?PHP
$var = 123; // Put the number 123 in the variable $var.
PHP?>


Below is an example of what you can do with PHP. It will be commented so you can follow along.
This is how it works:
Check to see if the user has specified their name. If not, display a form so they can enter there name. If they have entered there name print "Hello, (user's name here)!".
CODE
<?PHP //Tell the server that to process the PHP.
if ($_GET['name'] <> "")  //If statements do not need semicolons.
{ //This just means this is where the code for the if statement starts.
// This code is run if they have specified their name.  The <> means not equal.
$user_name = $_GET['name']; //Put the user's name is $user_name.
echo("Hello, $user_name");
}
else // This means that the user did not specify a name yet.
{
echo("Please type your name and press Submit:");
echo("<FORM ACTION='3.php' METHOD='GET'>");
//Notice I am using single quotes inside of echo.  If you were to use double quotes you would crash your program.
echo("<INPUT TYPE='text' NAME='name' LENGTH='30'>");
echo("<INPUT TYPE='Submit' VALUE='Submit'>");
}
PHP?>


I really hoped this helps some people start to learn PHP. Any questions, comments or constructive critiscism (this is my first tutorial) can be posted and I will answer them. I'll post the links to the 3 examples (Hello World, Hello World (with a variable), and the example once I get enough credits to become active again smile.gif.

 

 

 


Reply

NeOniX
Well, i want to colaborate with this post so i expose lil thingz related to simple maths to be used in PHP:

Operators are the common on most of programming languages, * for multiplying (3x2 = 3*2), + for sum (3+2 = 5), - for resting (3-2 = 1), / for division (3/2=1.5), and ^ for exponentials (3^2 = 9).

So if you want to sum some stored variables (of a DB, or whatever you want/need biggrin.gif) you could do the next:
CODE

<?
$var1= '3';  // that could come from a form if you replace the '3' string with a $_GET[''] or $_POST['']
$var2= '2';  // ... the same :P

settype($var1, 'integer');  // That makes a string into an integer, i.e. '5a' it will be converted into the number 5.
settype($var2, 'integer');  // The same for the $var2

/* You could ask why didnt i wrote "$var1=3;" instead of "$var1='3'", i did that cuz in the forms most of times is sent as a string, and the ppl could write 5a, 3v, c, so the settype makes the string to an integer (the integers dont have ' for delimitating) */

$sum = $var1+$var2;
echo $var1.' and '.$var2.' equals to '.$sum; // You'll have to get something like "3 and 2 equals to 5"
?>


It was a micro help, but from that, you could figure out to use -, *, / and ^ hehe.

 

 

 


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*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : basic, php

  1. Archive.org The Public Domain And Basic Copyright
    Archive.org is a great place to download old movies and things. (1)
  2. Making A Simple Signature With Adobe Photoshop
    A tutorial to basic signature designing: By Accure (3)
    Specs Hardness: 4 / 10 Time: about 10 minutes Result: My .PSD File: Download it now!
    Needings: -Basic Photoshop knowlegend. -Adobe Photoshop CS2 (Or CS3/CS4) -Brushes set ( available
    here ) -A render ( available here ) Basic knowlegend: Steps: 01. Open Adobe Photoshop,
    and go File > New. 02. select the sizes Width: 350 pixels . Height: 150 pixels . Press OK .
    03. Press the button to maximize the window of your new project. 04. Fill your background with
    black (by using the "fill" function). 05. Press F5, click on the small arrow a....
  3. Basic Of Website Creation
    Get basic knowledge on website creation here (9)
    By basic, i mean reaaaal "BASIC". I know that its probably redundant info for so many of us, but I
    still would like you to add your bit into this post , so that newbies benefit from it.....
  4. Buliding A Basic Community Site
    Building Community With Joomla (2)
    Hi I am currently running a Joomla CMS webpage, and Google Adsense on my page has generated a
    reasonable sum. I have used Joomla to build this webpage at the grounding and now with all the
    extension, it has become a money making webpage. I encourage all to try out this great CMS system.
    Here are some extentions I would reccomend. CB Bulider. Expose 4, Jambook, Ako Comment. Cheers.....
  5. A Twist On Basic Authentification
    html help (1)
    Alright, i am working on a website where a number of different users from different companies will
    be looking hooking into one website. What i want is to know how i can differentiate between the
    users based on the information passed by the webserver. I've been told to that information
    will be passed along html_user(and if i have a distinct user then i can just query the database with
    that info and get what i want) But how does this work? I am sorry i know this is cryptic i'm
    kind of searching to see if this strikes a bell with anyone. So to sum, many user....
  6. Ti Basic: Pick A Number
    (1)
    Description Learn how to create a neat-o Game in TI Basic. Its basic premise is that someone
    picks a number, then they pass the calculator to their friend, and they try to guess the number.
    Once the successfully guess the number a message appears and says that they have won. I have also
    included a line that keeps users from choosing numbers greater than one-hundred. Please Enjoy.
    Try I Out Alright.... just input what you see below and I'll explain it a little below.
    CODE :ClrHome :Lbl 2 :Prompt A :A->X :If X>100 :Goto 2 &#....
  7. Aob Blood Grouping
    Few Basic Idea for all (4)
    AOB blood grouping is the most common blood grouping in present world. In this grouping blood
    grouped depending on presence and absence of antigen A and antigen B in blood. Blood groups in AOB
    system are A, B, AB and O. I am trying to explain this blood grouping system as easy as possible so
    that the member of this site who has no science background can also understand the system. If any
    blood contain antigen A but no antigen B, the blood group will be A blood group. If any blood
    contains antigen B but no antigen A, the blood group will be B blood group. If any blood co....
  8. Ti-basic --- Slot Machine
    (9)
    Description Ok, so this is my first TI-BASIC tutorial. In this tutorial you will learn how to
    create a very simple slot machine, so you can entertain yourself in math class /tongue.gif"
    style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> You will need at least a TI
    83 Calculator. Try it out Ok, first create a new program called 'SLOT MACHINE'. Hit the
    enter key. Now input the following code. CODE :ClrHome :Lbl 1
    :Output(1,1,"--Slot Machine--") :Output(2,1,randInt(0,9,1))
    :Output....
  9. Some Basic But Important Info About Cancer
    (3)
    Symptoms of Cancer 1. Lumps, especially those that are growing larger gradually, appearing on parts
    of your body such as the breasts, neck abdomen. 2. Signs of injury not externally inflicted which
    do not go away after a long time, such as bruises and scratches on the skin or ulcers on the tongue
    3. Body weight keeps fluctuating or nutrition level decreases dramatically (e.g. falling sick more
    frequently or feel tired easily) despite the absence of sicknesses that also cause such symptoms
    such as Diabetes. 4. Dry cough that does not heal in a long while, blood in phl....
  10. Photoshop Tut: Basic Text (video)
    (0)
    Same thing as my sig tut, but for text. http://youtube.com/watch?v=SDFfVDSBhrY ....
  11. Photoshop Tut: Basic Sig (video)
    (0)
    This tutorial is for BEGINNERS who want to make a basic signature. And yeah I know, I have a weird
    squeaky voice :3 http://youtube.com/watch?v=9HE0C15uP80 ....
  12. Ftp In Visual Basic 6.0
    Start making your FTP client using VB6 (1)
    Recently, I had a need to make a FTP client, since our webhosting FTP server was kind of exotic, and
    very restrictive, and most of uploads, even though they reach 100% would crash... File would be
    uploaded to a server, but FTP clients just froze upon completion, waiting for the 226 (OK) from FTP
    server... So, I had to make my own, one who would not wait for 226, but instead, watch the file
    pload progress... This tutorial is not fuly complete, in the sense that it does not offer COMPLETE
    FTP client functionality (for example, I ddn't write the code for FTP download, ....
  13. Two Really Good 2d Mmo Engines
    One is pretty basic, the other one is for top notch programmers. (1)
    AlterEngine MMO engine that lets you edit and create a new world. Just run the server and
    distribute the game client, it's simple to use and effective for non commercial MMOs. It's
    mother language is spanish, so unless you know spanish, I wouldn't recommend this. This Engine
    doesn't require much Programming Experience. vbGORE Great MMO Engine, very powerful. Runs
    with VB6, fully editable. It's free and open source. It can achieve great things if you have the
    time and potential to script neat VB6 functions with Packet related coding and knowledg....
  14. Basic Percussion Composition
    (0)
    HI and welcome to the first tutorial you will have to firgive me as i am not a verry good
    speller. now as its the first tutorial im not going to go into allot of detale but if you get
    confused or need anny more help then just post a request for a tutorial on a specific area and ill
    see what i can doo. Tutorial 1 This tutorial will be based on your standard setup. to start its
    allways good to have a beggining setup now i major in dance type music so i work with a standard
    setup of something along the lines of a simple kick drum a group of two and a clap th....
  15. Basic C++ : Tutorial 2
    (0)
    Outline for Tutorial 2: a)Pseudo code for Program 2 b)Writing Program 2: the if statement
    c)Enrichment:creating readable output d)Relational operators,compound assignment operators e)Data
    types float, double, char f)Enrichment: debugging -Summary and Exercises Problem #2: A program is
    required that determines if or if not a person can register for courses based a specific formula.
    The person's GPA is plugged into the formula result = formula(GPA) and tested if or if it is
    not greater than zero. If it is greater than zero, the program will print "Admit". Construct ....
  16. [vb.net 2k5] Countdown (help)
    countdown visual basic 2005 2k5 (2)
    Hello, i'm having some troubles creating a countdown, i'm willing for some help. First of
    all, the form has a textbox where the user has to input the time to countdown like this: 1:10 the
    form has also 3 labels, 1 named countminutes, other countseconds and another label1 with the text
    ":" here's the code, the problem is that it counts the time, but blocks the app till it ends,
    wich result on not showing the counttime like it should: Imports System.Threading.Thread Public
    Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As ....
  17. Help! Php Or Just Html?
    i want to start buliding my website. which is better, php or basic htm (13)
    i try to start this topic in webhost category but it seems like i cant. i dont have the permission
    so i just post my topic here. im sorry mod.. i want to build a website which contains: - Links to
    videos - Informations - photos - flash i don't know if i should use php or just HTML. guys,
    what are your opinions..??....
  18. Mysql In Visual Basic
    Mysql in visual basic (5)
    I'm am trying to create a script so that visual basic 6 can interact with mysql Any ideas?....
  19. Learn Russian
    Basic Stuff You Need To Know (7)
    Learning Russia Lesson 1 - Basic Words ~~~~~~ Hello - privyet (informal hello) Hello - zdrastye
    (formal hello) Bye - poka How are you - kak dila Good/Wll - horosho Ok/Normal - normalno Poor/Bad -
    Ploka ---More Words Yet To Come--- ---Study Makes Perfect--- I am going to make a quiz over this
    so you all better be ready =). I hope I inspire you to learn russian. Its a great language plus I am
    russian as a russian respects mother russia we respect all so I am sharing top language (not really
    top) to you. L = Lesson Quiz - Over L1 http://www.quizyourfriends.com/quizp....
  20. Creating A Timer Program
    Using Visual Basic 2005 (8)
    This tutorial will explain how to create a basic timer using Visual Basic Express 2005. If you
    don't have it, it's free and you can dowload it from Microsoft's website. All you need
    is a few minutes to sit down and read this and a version of Visual Basic. OK, so what will this
    timer actually do? Well, you are able to enter a number of minutes and a message, and then click a
    button. Once the timer is up, your message pops up and you are reminded! So, basically it's
    a little reminder system. I use it to remind me when TV programmes start, when I have to....
  21. Simple C File Handling In Action
    Small code snipet which covers most of basic file handling and navigat (4)
    Yesterday I suddenly got a lot of work. The same work we try to push off, yes you are right all
    formalities to get the code review incorporated and update all source code files with code review
    headers. Imagine if you need to open 300 files one by one and append code review headers at the
    end. Since most files are reviewed in groups of 20 to 30 files. We require one header to be placed
    in say 20 to 30 files. To simplify I went back to my class assignment days and wrote this small c
    utility to open all files passed on command line and open attach code review headers an....
  22. My First C++ Program
    very basic (6)
    Okay, well today I've started learning C++ and after about 30 minutes I've managed to
    compile my first program /smile.gif" style="vertical-align:middle" emoid=":)" border="0"
    alt="smile.gif" /> All it does is prompt you to type a number in between 1 and 10. If it's not
    in that range, it adds/subtracts until it is. The best part is you get to see it add/subtract the
    numbers up one-by-one! Code: #include using namespace std; int main() {
    // Define variables int anumber; cout cin>> anumber; cin.ignore....
  23. Basic Ways To Speed Up Your Web Site
    (25)
    Speed is certainly one of the most important factors when it comes to making a successful web site.
    These days’ people have high expectations, they expect a web site to load as fast as an application
    on their operating system, and therefore even a few seconds of waiting can frustrate them or leave
    altogether. A good website should take about 8-12 seconds (for a 56K) to load. The website owner is
    going to have to decide how fast its pages are going to be, for example for a multimedia or a flash
    site they can afford to be a bit slower than others provided that the users k....
  24. How To Make A Web Browser
    Visual Basic 6 (49)
    This is a simple and specific tutorial on how to make a basic web browser in Visual Basic 6. Steps
    1-3 Create a new project, and then go to "Project" on the menu. Click components as shown in the
    following image. Find the component "Microsoft Internet Controls," check it, and click "Apply" and
    then "Close." Click the icon that was just added in the tools window, and draw a large sized
    window with it. This is going to be where you view webpages through your browser, so don't make
    it small, but leave room for buttons and other accessories. Steps 4-6 Make a t....
  25. Visual Basic 6.0 Help Needed
    Adding lines to a textbox without delete (15)
    I need help with Visual Basic 6.0 and adding lines to a textbox without deleting any previous
    lines.. I've gotten as far as finding a way to add the lines, but it deletes the prevous entree.
    Help is appreciated!....
  26. Java Basic Program Guidance
    (6)
    aving some problems taking in the Java at Uni, Was wondering if anyone could shine some light on it
    for me. My task is to write a program that will ask you to enter 2 words. the program will then
    print out both words on one line. However the words will be seperated by dots that will make the
    total length of the line 40. so if your first word was turtle and the second was abc, the output
    would be turtle...............................abc The program should check for certain conditions:
    1. a word can not be longer than 37 characters; 2. there must always be atlest 2 do....
  27. Simple Login In Visual Basic 6
    user interaction example trough login programm (6)
    First of all, I am NOT a programmer, this is something my friend taught me. It describes basic
    interaction with the user, while showing basic functionality of this simple programm. So, without
    further ado, we're off to the tutorial: First of all, start your visual basic, when prompted
    for new project, select Standard Exe . Next, we need to open code window, so we can start typing
    the program. This can be done in two ways, one is double clicking on the form, or selecting Code
    from View menu. If you double clicked on the form, you will see following text: CODE ....
  28. [tutorial] Visual Basic 6 Minimize To Tray
    Minimize to Tray (7)
    This example will "minimize" your program to the system tray when you click on a button, and restore
    it when you click the system tray icon. For this example you'll need: 1 Form - Form1 1 button -
    Command1 Add a Module to your project, and ad this code: CODE ' Create an Icon in System
    Tray Needs Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long
    uCallBackMessage As Long hIcon As Long szTip As String * 64 End Type Public Const NIM_ADD = &H0
    Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const WM_MOUSEMOVE ....
  29. [tutorial] Visual Basic 6
    Closing Programs Right, Why END is bad (4)
    This tutorial applies to all those people who insist upon using "End" to close their programs: End
    stops the program immediately without any thought as to what's going on - it's like a high
    speed train hitting a brick wall. It can cause unwanted errors and is bad programming practice in
    general. END gets rids of the form, but NOT its leftovers. This leaves a bunch of memory that will
    still be in use even after your program has supposedly closed. An object or variable won't be
    terminated properly - it's just not a graceful exit. The only time that it'....
  30. Need Help With My Python Programs
    just extremely basic stuff (11)
    ok, i am learning python, and i realy dont know much. my guide im using said to make a program
    where it asks your name, and if the name is yours your make it so there is a compliment, if it is
    another name you make it that its an insult, and anything else makes it say Nice name. here is what
    i wrote name = raw_input("What is your name?") if name == John: print "Your name is freaking
    sweet, you must be a god or something." elif name == Bob: print "You have a freakin' weird
    name, dude." else: print "Nice name,",name i donot understand what i am doing w....

    1. Looking for basic, php

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for basic, php

*MORE FROM TRAP17.COM*
Similar
Archive.org The Public Domain And Basic Copyright - Archive.org is a great place to download old movies and things.
Making A Simple Signature With Adobe Photoshop - A tutorial to basic signature designing: By Accure
Basic Of Website Creation - Get basic knowledge on website creation here
Buliding A Basic Community Site - Building Community With Joomla
A Twist On Basic Authentification - html help
Ti Basic: Pick A Number
Aob Blood Grouping - Few Basic Idea for all
Ti-basic --- Slot Machine
Some Basic But Important Info About Cancer
Photoshop Tut: Basic Text (video)
Photoshop Tut: Basic Sig (video)
Ftp In Visual Basic 6.0 - Start making your FTP client using VB6
Two Really Good 2d Mmo Engines - One is pretty basic, the other one is for top notch programmers.
Basic Percussion Composition
Basic C++ : Tutorial 2
[vb.net 2k5] Countdown (help) - countdown visual basic 2005 2k5
Help! Php Or Just Html? - i want to start buliding my website. which is better, php or basic htm
Mysql In Visual Basic - Mysql in visual basic
Learn Russian - Basic Stuff You Need To Know
Creating A Timer Program - Using Visual Basic 2005
Simple C File Handling In Action - Small code snipet which covers most of basic file handling and navigat
My First C++ Program - very basic
Basic Ways To Speed Up Your Web Site
How To Make A Web Browser - Visual Basic 6
Visual Basic 6.0 Help Needed - Adding lines to a textbox without delete
Java Basic Program Guidance
Simple Login In Visual Basic 6 - user interaction example trough login programm
[tutorial] Visual Basic 6 Minimize To Tray - Minimize to Tray
[tutorial] Visual Basic 6 - Closing Programs Right, Why END is bad
Need Help With My Python Programs - just extremely basic stuff
advertisement



Basic Php Tutorial



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE