HOME       >>       Programming

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.

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

 

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

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 ?


FirefoxRocks

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


yordan

PHP = PHP: Hypertext Preprocessor

 

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

Now I see :

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.

ozgur1405241561


ryantommo

thanks alot man


Bermuntas

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


yordan

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 ?

Danzo0991

awesome tudo man


hfbvm

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.

yordan

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

thanks

hfbvm

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


yordan

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...


VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.