Tuesday, 14 January 2014
Labels:
learn
,
Php
,
Tutorial
A complete PHP Tutorial For Beginners To Learn PHP Basic Part 1
Posted by
Unknown
at
22:45
PHP is a powerful tool for making dynamic and interactive Web pages. PHP is the widely used, free, and efficient alternative to competitors such as Microsoft's ASP. In this PHP tutorial you will learn about PHP Basics.
INTRODUCTION
PHP
- PHP stands for PHP: Hypertext Preprocessor
- PHP is a server-side scripting language, like ASP
- PHP files can contain text, HTML tags and scripts
- PHP files have a file extension of ".php", ".php3", or ".phtml"
MYSQL
- MySQL is a database server.
- mMySQL is ideal for both small and large applications
- MySQL supports standard SQL.
PHP Syntax
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.
- <?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".
- The file must have a .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>
Variables in PHP
- All variables in PHP start with a $ sign symbol. The correct way of declaring a variable in PHP.
- $var_name = value;
Naming Rules for Variables
- A variable name must start with a letter or an underscore "_"
- A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )
- A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_string), or with capitalization ($myString)
PHP Operators
Arithmetic Operators
- Addition (+)
- Subtraction(-)
- Multiplication(*)
- Division(/)
- Modulus [division remainder] (%)
- Increment(++)
- Decrement(--)
Assignment Operators
- =
- +=
- -=
- *=
- /=
- .=
- %=
Comparison Operators
- is equal to(==)
- is not equal(!=)
- is not equal(<>)
- is greater than(>)
- is less than(<)
- is greater than or equal to(>=)
- is less than or equal to(<=)
Logical Operators
- and(&&)
- or(||)
- not(!)
If you like my blog please like and share it. thank you.
Subscribe to:
Post Comments
(
Atom
)
Gud Tutorial for Beginners
ReplyDelete