Saturday, 27 August 2011

PHP TUTORIAL VIDEO PAGE 5




29)CHECKING USERNAME FOR GAME




30)CHECK FOR DUPLICATE NAMES IN GAMES




31)TEST FOR SPAMMERS AND HACKER ON PHP GAME



32)EMAIL CONFIRMATION FOR PHP



33)GETTING TEMPRORY DATA FOR PHP GAME



34)CREATING TABLES FOR PHP GAME


35)DELETING DATA FROM TEMP TABLE FOR PHP



PAGE NO. 1 2 3 4 5

PHP TUTORIAL VIDEO PAGE 4




22)CREATING A MY SQL DATABASE



23)ADDING TABLE TO MY SQL DATABASE



24)CONNECTING TO MY SQL DATABASE




25)SELECTING A MY SQL DATABASE



26)TESTING THE DATABASE CONNETION



27)CREATING COMPUTER GAME



28)CREATING CONNECTION AND TABLE FOR GAME



PAGE NO. 1 2 3 4 5

PHP TUTORIAL VIDEO PAGE 3



15)FUNCTIONS



16)PARAMETRIC FUNCTIONS



17)RETURN VAULUES



18)BEGINING FORMS



19)MORE ON FORMS



20)DATE FUNCTION



21)INCLUDE FUNCTION


PAGE NO. 1 2 3 4 5

PHP TUTORIAL VIDEO PAGE 2


8)DO LOOP



9)FOR LOOP



10)ARRAYS



11)ASSOCIATIVE ARRAY



12)ADDING AND MODIFYING ELEMENTS

IN ARRAY


13)ARRAYS WITH LOOP



14)FOREACH ARRAY LOOP



PAGE NO. 1 2 3 4 5

Monday, 22 August 2011

PHP BASICS


PHP is a server-side scripting language.

What You Should Already Know

Before you continue you should have a basic understanding of the following:
  • HTML/XHTML
  • JavaScript
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: www.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

PHP Date() Function


PHP Date() Function



The PHP date() function is used to format a time and/or date.

PHP Date() - Format the Date

The required format parameter in the date() function specifies how to format the date/time.
Here are some characters that can be used:
  • d - Represents the day of the month (01 to 31)
  • m - Represents a month (01 to 12)
  • Y - Represents a year (in four digits)
A list of all the characters that can be used in the format parameter, can be found in our PHP Date reference.
Other characters, like"/", ".", or "-" can also be inserted between the letters to add additional formatting:



<?php
 echo date("Y/m/d") . "<br />";
 echo date("Y.m.d") . "<br />";
 echo date("Y-m-d");
?> 




The output of the code above could be something like this:

Output

2009/05/11
2009.05.11
2009-05-11

PHP Functions


PHP Functions


The real power of PHP comes from its functions.
In PHP, there are more than 700 built-in functions.

PHP Built-in Functions

For a complete reference and examples of the built-in functions, please visit our PHP Reference.

PHP Functions

In this chapter we will show you how to create your own functions.
To keep the script from being executed when the page loads, you can put it into a function.
A function will be executed by a call to the function.
You may call a function from anywhere within a page.

Create a PHP Function

A function will be executed by a call to the function.

Syntax

function functionName()
{
code to be executed;
}




PHP function guidelines:
  • Give the function a name that reflects what the function does
  • The function name can start with a letter or underscore (not a number)

Example

A simple function that writes my name when it is called:
PHP Code

function writeName()
{
echo "SamGenius";
}

echo "My name is ";
writeName();



output


My name is Samgenius






PHP Functions - Adding parameters

To add more functionality to a function, we can add parameters. A parameter is just like a variable.
Parameters are specified after the function name, inside the parentheses.

Example 1

The following example will write different first names, but equal last name:

PHP Code

function writeName($fname)
{
echo $fname . " Refsnes.<br />";
}

echo "My name is ";
writeName("Kai Jim");
echo "My sister name is ";
writeName("Hege");
echo "My brother name is ";
writeName("Stale");



output


My name is Kai Jim Refsnes.
My sister name is Hege Refsnes.
My brother name is Stale Refsnes.






PHP Functions - Return values

To let a function return a value, use the return statement.

Example


<?php
 function add($x,$y)
 {
  $total=$x+$y;
  return $total;
 }

 echo "1 + 16 = " . add(1,16);
?> 

PHP Looping - For Loops


PHP Looping - For Loops



Loops execute a block of code a specified number of times, or while a specified condition is true.

The for Loop

The for loop is used when you know in advance how many times the script should run.

Syntax

for (init; condition; increment)
  {
  code to be executed;
  }




Parameters:
  • init: Mostly used to set a counter (but can be any code to be executed once at the beginning of the loop)
  • condition: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
  • increment: Mostly used to increment a counter (but can be any code to be executed at the end of the loop)
Note: Each of the parameters above can be empty, or have multiple expressions (separated by commas).

Example

The example below defines a loop that starts with i=1. The loop will continue to run as long as i is less than, or equal to 5. i will increase by 1 each time the loop runs:


PHP Code

for ($i=1; $i<=5; $i++)
  {
  echo "The number is " . $i . "
";
  }





OUTPUT



The number is 1
The number is 2
The number is 3
The number is 4
The number is 5



The foreach Loop

The foreach loop is used to loop through arrays.
Syntax

foreach ($array as $value)
  {
  code to be executed;
  }




For every loop iteration, the value of the current array element is assigned to $value (and the array pointer is moved by one) - so on the next loop iteration, you will be looking at the next array value.

Example

The following example demonstrates a loop that will print the values of the given array:

PHP Code

$x=array("one","two","three");
foreach ($x as $value)
  {
  echo $value . "
";
  }



OUTPUT
one
two
three



try it your self



<?php
  for ($i=1; $i<=5; $i++)
  {
  echo "The number is " . $i . "<br />";
  }


//----------www.phptry.com-----------


  $x=array("one","two","three");
  foreach ($x as $value)
  {
  echo $value . "<br />";
  }


?>
Share on Tumblr