Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

language.operators.increment function syntax tag tutorial 2013





Alert! Connect with 10,000 Chating Online. Join Now

Php language.operators.increment () function

Write your php code

 
<?php ?>

Php Result


Your code below



Incrementing/Decrementing Operators

PHP supports C-style pre- and post-increment and decrement operators.

Table 15-5. Increment/decrement Operators

ExampleNameEffect
++$aPre-incrementIncrements $a by one, then returns $a.
$a++Post-incrementReturns $a, then increments $a by one.
--$aPre-decrementDecrements $a by one, then returns $a.
$a--Post-decrementReturns $a, then decrements $a by one.

Here's a simple example script:

<?php
echo "<h3>Postincrement</h3>";
$a = 5;
echo
"Should be 5: " . $a++ . "<br />\n";
echo
"Should be 6: " . $a . "<br />\n";

echo
"<h3>Preincrement</h3>";
$a = 5;
echo
"Should be 6: " . ++$a . "<br />\n";
echo
"Should be 6: " . $a . "<br />\n";

echo
"<h3>Postdecrement</h3>";
$a = 5;
echo
"Should be 5: " . $a-- . "<br />\n";
echo
"Should be 4: " . $a . "<br />\n";

echo
"<h3>Predecrement</h3>";
$a = 5;
echo
"Should be 4: " . --$a . "<br />\n";
echo
"Should be 4: " . $a . "<br />\n";
?>

PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in Perl 'Z'+1 turns into 'AA', while in C 'Z'+1 turns into '[' ( ord('Z') == 90, ord('[') == 91 ). Note that character variables can be incremented but not decremented.

Example 15-3. Arithmetic Operations on Character Variables

<?php
$i
= 'W';
for(
$n=0; $n<6; $n++)
  echo ++
$i . "\n";

The above example will output:

X
Y
Z
AA
AB
AC

Incrementing or decrementing booleans has no effect.

Php language.operators.increment Function syntax tag

language.operators.increment php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php language.operators.increment syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online