|
What Is PHP?
|
PHP stands for Hypertext Preprocessor and is a server-side scripting language.
A D V E R T I S E M E N T
It means that the script is run on web browser and not on users browser.
Therefore there is no need to worry about compatibility issues. PHP is comparitively
new language unlike Perl (CGI) and Java). PHP is becoming one of the
most popular scripting language on the internet.
|
General Syntax for PHP
|
PHP scripts should always be enclosed in between two PHP tags. This tells the
server to parse all the information between them as PHP code. The three different
ways for this are as follows:
|
<?
Here is a PHP Code
?>
|
<?php
Here is a PHP Code
php?>
|
<script language="php">
Here is a PHP Code
</script>
|
|
Rules for Variable Naming
|
- A variable name should always start with a letter or an underscore "_"
-
A variable name only contains underscores and alpha-numeric characters
(a-Z, 0-9, and _ )
- A variable name should not contain spaces in between. If the variable name should be of more
than one word, it should be separated by underscore (like $my_string), or with
capitalization ($myString)
|
Operators that are used in PHP
|
- Assignment Operator
- Dot Operator
- Arithmetic Operators
- Comparison Operators
|
include()
|
The include() function includes and evaluates the specified file.
The include() statement takes all the contents of the specified file and
copies it to the one which consist this statement.
|
require().
|
Similarly the require() statement includes and evaluates the specified file.
Both include() and require() works in same way, the only difference is how they handle
failure. The include() statement produces warning, but the script will continue its
execution. While the require() statement produces a Fatal Error and script stop its execution..
|
Cookie can be accessed in three ways by a PHP script:
|
In a cookie there are information about a name, value, expiry date, host and path.
As cookies are sent from server through HTTP header, they end up to the user.
Here are the 3 ways to access cookies:
- using �$HTTP-COOKIE� which is the environmental variable, all cookie names
and values are present in this variable.
-
using global variable �$cookie_name�, here the name should be replaced
- using �HTTP_COOKIE_VARS [�cookie_name�]� which is a global array variable.
(here replace the �cookie_name� by actual name of the cookie).
|
The difference between sessions and cookies
|
The main difference between sessions and cookies is that a session can hold multiple
variables, and you need not have to set cookies for every variable. By default, the
session data is stored in the cookie wich has an expiry date of zero, which means that
the session remains active only as long as the browser.Once you close the browser, all
the stored information is lost. This behavior can be modified by changing the �session.
cookie_lifetime� setting in �php.ini� from zero to whatever you want the cookie
lifetime to be.
|
The Role Of MySQL DataBase
|
we can summarize the process of accessing and working with a database connection
from within a PHP script in the following steps.
-
First you need to establish a connection to the database server.
-
You should have to validate any user input
-
Then select the database on the server to use.
-
Execute all the desired query against the database.
-
Furter retrieve and process the results.
-
Then create HTML or perform actions based on results.
-
Finally close the database connection.
|
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords:php tutorial, php scripts, php nuke, php download, php editor, php mysql, php forum,
php add link, learn php, php code
|
|
HTML Quizzes |
|
XML Quizzes |
|
Browser Scripting Quizzes |
|
Server Scripting Quizzes |
|
.NET (dotnet) Quizzes |
|
Multimedia Quizzes |
|
Web Building Quizzes |
|
Java Quizzes |
|
Programming Langauges Quizzes |
|
Soft Skills Quizzes |
|
Database Quizzes |
|
Operating System Quizzes |
|
Software Testing Quizzes |
|
SAP Module Quizzes |
|
Networking Programming Quizzes |
|
Microsoft Office Quizzes |
|
Accounting Quizzes |
|
|