Nov 25, 2009
Pages: 1, 2

Php:lesson #1 - The basics of PHP.

free web hosting

Read Latest Entries..: (Post #12) by yordan on Apr 11 2009, 04:24 PM.
QUOTE (hfbvm @ Apr 10 2009, 08:12 PM) your welcome hope i find more spammers.LOL.if you are not able to find them. I must protest against that. I am not unable to find them. Simply, maybe I'm a little bit slow...
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion & Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > PHP

Php:lesson #1 - The basics of PHP.

Archimedes
QUOTE
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

Notice from Yordan:
copied from w3schools.com under php section pages 1,3,4

 

 

 


Comment/Reply (w/o sign-up)

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 ?

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

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.

Comment/Reply (w/o sign-up)

ozgur
biggrin.gif

Comment/Reply (w/o sign-up)

ryantommo
thanks alot man

Comment/Reply (w/o sign-up)

Bermuntas
Good lesson, i know where did you found it. "w3schools"

Comment/Reply (w/o sign-up)

yordan
QUOTE (Bermuntas @ Jan 28 2009, 05:41 PM) *
Good lesson, i know where did you found it. "w3schools"

Do you mean that this topic is copied from a page in w3schools ? Could you please post the link to that page ?

Comment/Reply (w/o sign-up)

Danzo0991
awesome tudo man

Comment/Reply (w/o sign-up)

hfbvm
here's the whole document:
QUOTE
What You Should Already Know

Before you continue you should have a basic understanding of the following:

* HTML
* Some scripting knowledge

If you want to study these subjects first, find the tutorials on our Home page.
What is PHP?

* PHP stands for PHP: Hypertext Preprocessor
* PHP is a server-side scripting language, like ASP
* PHP scripts are executed on the server
* PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
* PHP is an open source software
* PHP is free to download and use

What is a PHP File?

* PHP files can contain text, HTML tags and scripts
* PHP files are returned to the browser as plain HTML
* PHP files have a file extension of ".php", ".php3", or ".phtml"

What is MySQL?

* MySQL is a database server
* MySQL is ideal for both small and large applications
* MySQL supports standard SQL
* MySQL compiles on a number of platforms
* MySQL is free to download and use

PHP + MySQL

* PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform)

Why PHP?

* PHP runs on different platforms (Windows, Linux, Unix, etc.)
* PHP is compatible with almost all servers used today (Apache, IIS, etc.)
* PHP is FREE to download from the official PHP resource: www.php.net
* PHP is easy to learn and runs efficiently on the server side

Where to Start?

To get access to a web server with PHP support, you can:

* Install Apache (or IIS) on your own server, install PHP, and MySQL
* Or find a web hosting plan with PHP and MySQL support
Basic PHP Syntax

A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.

On servers with shorthand support enabled you can start a scripting block with <? and end with ?>.

For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.

<?php

?>

A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.

Below, we have an example of a simple PHP script which sends the text "Hello World" to the browser:

<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>

Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.

There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".

Note: The file must have the .php extension. If the file has a .html extension, the PHP code will not be executed.
Comments in PHP

In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.

<html>
<body>

<?php

//This is a comment

/*
This is
a comment
block
*/

?>

</body>
</html>Basic PHP Syntax

A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.

On servers with shorthand support enabled you can start a scripting block with <? and end with ?>.

For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.

<?php

?>

A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.

Below, we have an example of a simple PHP script which sends the text "Hello World" to the browser:

<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>

Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.

There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".

Note: The file must have the .php extension. If the file has a .html extension, the PHP code will not be executed.
Comments in PHP

In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.

<html>
<body>

<?php

//This is a comment

/*
This is
a comment
block
*/

?>

</body>
</html>

He copied it from w3schools.com under php section pages 1,3,4 check it out mod.

 

 

 


Comment/Reply (w/o sign-up)

Latest Entries

yordan
QUOTE (hfbvm @ Apr 10 2009, 08:12 PM) *
your welcome hope i find more spammers.LOL.if you are not able to find them. laugh.gif

I must protest against that. I am not unable to find them. Simply, maybe I'm a little bit slow... rolleyes.gif

Comment/Reply (w/o sign-up)

hfbvm
your welcome hope i find more spammers.LOL.if you are not able to find them. laugh.gif

Comment/Reply (w/o sign-up)


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*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2

See Also,

*SIMILAR VIDEOS*
Searching Video's for php, lesson, 1, basics, php,
advertisement



Php:lesson #1 - The basics of PHP.

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com