> 2012 ~ Online tutorial

foreach statement in php

foreach Statement: The foreach statement is used to loop through arrays. For every loop, the value of the current array element is assigned to $value (and the array pointer is moved by one) so on the next loop, you'll be looking at the next element. Syntax foreach (array as value) { code to be executed; } Example <html> <body> <?php...

for Statement in php

for Statement The for statement is used when you know how many times you want to execute a statement or a list of statements. Syntax for (initialization; condition; increment) { code to be executed; } Note: The for statement has three parameters. The first parameter initializes variables, the second parameter holds the condition, and the third...

do...while Statement in php

The do...while Statement The do...while statement will execute a block of code at least once - it then will repeat the loop as long as a condition is true. Syntax do { code to be executed; } while (condition); Example The following example will increment the value of i at least once, and it will continue incrementing the variable i as...

while statement in php

The while Statement The while statement will execute a block of code if and as long as a condition is true. Syntax while (condition) code to be executed; Example The following example demonstrates a loop that will continue to run as long as the variable i is less than, or equal to 5. i will increase by 1 each time the loop runs: <html>...

Looping in php

PHP Looping: Looping statements in PHP are used to execute the same block of code a specified number of times. Looping Very often when you write code, you want the same block of code to run a number of times. You can use looping statements in your code to perform this. In PHP we have the following looping statements: • while - loops through...

Multidimensional Arrays in php

Multidimensional Arrays In a multidimensional array, each element in the main array can also be an array. And each element in the sub-array can be an array, and so on. Example In this example we create a multidimensional array, with automatically assigned ID keys: $families = array ( "Griffin"=>array ( "Peter", "Lois", "Megan" ), "Quagmire"=>array...

Associative Array in php

Associative Arrays An associative array, each ID key is associated with a value. When storing data about specific named values, a numerical array is not always the best way to do it. With associative arrays we can use the values as keys and assign values to them. Example 1 In this example we use an array to assign ages to the different persons:...

Numeric array in php

Numeric Arrays A numeric array stores each element with a numeric ID key. There are different ways to create a numeric array. Example 1 In this example the ID key is automatically assigned: PDF by Hans Home Collection $names = array("Peter","Quagmire","Joe"); Example 2 In this example we assign the ID key manually: $names[0] = "Peter";...

php array

PHP Arrays An array stores multiple values in one single variable.What is an Array? A variable is a storage area holding a number or text. The problem is, a variable will hold only one value. An array is a special variable, which can store multiple values in one single variable. If you have a list of items (a list of car names, for example), storing...

Strpos() function in php

strpos() function The strpos() function is used to search for character within a string. If a match is found, this function will return the position of the first match. If no match is found, it will return FALSE. Let's see if we can find the string "world" in our string: < ?php echo strpos("Hello world!","world"); ? > The output of the...

strlen() function in php

strlen() function The strlen() function is used to return the length of a string. Let's find the length of a string: <?php echo strlen("Hello world!"); ? > The output of the code above will be: 12 The length of a string is often used in loops or other functions, when it is important to know when the string ends. (i.e. in a loop, we would...

Concatenation operator in php

The Concatenation Operator There is only one string operator in PHP. The concatenation operator (.) is used to put two string values together. To concatenate two string variables together, use the concatenation operator: Example ?php $txt1="Hello World!"; $txt2="What a nice day!"; echo $txt1 . " " . $txt2; ? The output of the code above will...

String in php

PHP String Variables A string variable is used to store and manipulate text. String Variables in PHP String variables are used for values that contains characters. In this chapter we are going to look at the most common functions and operators used to manipulate strings in PHP. After we create a string we can manipulate it. A string can be used directly...

String Operators in php

 String Operators As we have already seen in the Echo Lesson, the period "." is used to add two strings together, or more technically, the period is the concatenation operator for strings.  PHP Code: $a_string = "Hello"; $another_string = " Billy"; $new_string = $a_string . $another_string; echo $new_string . "!"; Display:...

Comparison Operators in php

Comparison Operators Comparisons are used to check the relationship between variables and/or values. If you would like to see a simple example of a comparison operator in action, check out our If Statement Lesson. Comparison operators are used inside conditional statements and evaluate to either true or false. Here are the most important comparison...

Assignment Operators in php

Assignment Operators Assignment operators are used to set a variable equal to a value or set a variable to another variable's value. Such an assignment of value is done with the "=", or equal character. Example:  •  $my_var = 4;  •  $another_var = $my_var   Now both $my_var and $another_var contain the...

Php operator

Operators in PHP In all programming languages, operators are used to manipulate or perform operations on variables and values. You have already seen the string concatenation operator "." in the Echo Lesson and the assignment operator "=" in pretty much every PHP example so far.   There are many operators used in PHP, so we have separated...

Arithmetic Operators in php

Using Arithmetic Operators To perform mathematical operations on variables, use the standard arithmetic operators, as illustrated in the following example: <?php // define variables $num1 = 101; $num2 = 5; // add $sum = $num1 + $num2; // subtract $diff = $num1 - $num2; // multiply $product...

Data types in PHP

Understanding Simple Data Types Every language has different types of variables—and PHP has no shortage of choices. The language supports a wide variety of data types, including simple numeric, character, string, and Boolean types, and more complex arrays and objects. Data Type Description Example Integer An integer...

Writing Statements and Comments in php

Writing Statements and Comments As you can see from the previous example, a PHP script consists of one or more statements, with each statement ending in a semicolon. Blank lines within the script are ignored by the parser. Everything outside the tags is also ignored by the parser, and returned as is; only the code between the tags is read and...

Feature in PHP

Features As a programming language for the Web, PHP is hard to ignore. Clean syntax, object-oriented fundamentals, an extensible architecture that encourages innovation, support for both current and upcoming technologies and protocols, and excellent database integration are just some of the reasons for the popularity it currently enjoys in the...

Title Tag Optimization

1)Indicate page titles by using title tags A title tag tells both users and search engines what the topic of a particular page is. The <title> tag should be placed within the <head> tag of the HTML document (1). Ideally, you should create a unique title for each page on your site. <html> <head> <title>Brandon's...

SEO Tutorial for beginner

SEO SEO Interview Questi...

seo interview questions

1 ) What is Search Engines ?  Search Engine are Key of Finding Specific Information on the vast expanse of the World Wide Web 2 ) How to achieve Google Page Rank ?   Google Page Rank Largely Dependent on Links so more the Backlinks you have the more is your page rank it also affected by the rank of page linked to you. One other...

What is SEO

What SEO Is Search Engine Optimization refers to the collection of techniques and practices that allow a site to get more traffic from search engines (Google, Yahoo, Microsoft). SEO can be divided into two main areas: off-page SEO (work that takes place separate from the website) and on-page SEO (website changes to make your website rank better)....