Jump to content
xisto Community
Archimedes

Php:lesson #1 The basics of PHP.

Recommended Posts

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.

<?phpecho "Hello Xisto!";?>
Output: Hello Xisto!

 

3. All PHP statements end with a semicolon(:mellow:.(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.

<?php//This is a one lined comment(has no effect on the script, whatsoever)echo "Hello Xisto!";/*Thisis aComment block(has no effect on the script, whatsoever)*/?>
Output: Hello Xisto!

 

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($).

<?php$text = "Hello";$number = 4;echo $text;?>
Output: Hello

 

8. To type 2 variables after each other, you'd separate them with '. " " .', like so.

<?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
Edited by yordan (see edit history)

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

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

 

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

Edited by FirefoxRocks (see edit history)

Share this post


Link to post
Share on other sites

here's the whole document:

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: http://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.

Share this post


Link to post
Share on other sites

your welcome hope i find more spammers.LOL.if you are not able to find them. :o

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.