Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Php:lesson #1, The basics of PHP.
Archimedes
post Jul 28 2008, 11:37 AM
Post #1


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 8
Joined: 22-July 08
From: Pitcairn, PA
Member No.: 31,591



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

This post has been edited by Archimedes: Jul 31 2008, 06:56 PM
Go to the top of the page
 
+Quote Post
yordan
post Jul 28 2008, 12:55 PM
Post #2


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 2,186
Joined: 16-August 05
Member No.: 7,896
myCENTs:61.17



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 ?
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Jul 28 2008, 07:02 PM
Post #3


Super Member
Group Icon

Group: [HOSTED]
Posts: 737
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



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

This post has been edited by FirefoxRocks: Jul 28 2008, 07:03 PM
Go to the top of the page
 
+Quote Post
yordan
post Jul 28 2008, 08:18 PM
Post #4


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 2,186
Joined: 16-August 05
Member No.: 7,896
myCENTs:61.17



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.
Go to the top of the page
 
+Quote Post
ozgur
post Sep 14 2008, 10:39 AM
Post #5


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 1
Joined: 14-September 08
Member No.: 32,639



biggrin.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Switching Forms - VB.NET(2)
  2. The Very Basics Of Animation(8)
  3. Lesson #1 - Introduction To C#(1)
  4. Lesson #2 - Switch Statement In C#(1)
  5. [tutorial] Basics Of C Programming - Part 1(11)
  6. [tutorial] Basics Of C Programming - Part 2(21)
  7. The Basics Of Google Adsense(2)
  8. Programming In Glut (lesson 1)(3)
  9. Programming In Glut (lesson 3)(1)
  10. Programming In Glut (lesson 4)(7)
  11. Programming In Glut (lesson 6)(1)
  12. C# Tutorial : Lesson 1 - Hello World Program(0)
  13. C# Tutorial : Lesson 2 - Variables & Operators(0)
  14. C# Tutorial : Lesson 3 - Programming Constructs(1)
  15. C# Tutorial : Lesson 4 - Object Oriented Programming(2)
  1. C# Tutorial : Lesson 5 - Encapsulation & Abstraction(0)
  2. C# Tutorial : Lesson 6 - Creating Value Types & Reference Types - Part I(0)
  3. C# Tutorial : Lesson 7 - Creating Value Types & Reference Types - Part II(1)
  4. Basics Of Php For Beginners - Suggestion(5)
  5. Does Anyone Know Rpg Maker 2003(3)
  6. C# Tutorial : Lesson 8 - Functions/methods(0)
  7. C# Tutorial : Lesson 9 - Constructors & Destructors(0)
  8. Learning Php/sql Basics(17)
  9. Php Tutorial #1(0)
  10. Network Outage. Distribution Switch Ddosed.(5)
  11. Lesson Of The Day(5)
  12. Php: Lesson #2; If...else Statements.(1)
  13. Php: Lesson #3;functions(0)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 02:41 PM