Tuesday, January 13, 2009

Tutorials on php:Day 2


A variable is a special container that you can define, which will then contain a value you specify. For example a number, string, object, array or boolean.

If you want to work with a value that needs to remain unchanged, you can define and use a constant variable. This isdifferent to a variable as variables offer a flexible way of storing data as you can change their values and type of data they hold.

Globals and Superglobals
In addition to global declerations aof your own, PHP has built in predefined variables called superglobals. These are always present and the value they hold can be available in all your scripts.

Predefined Constants
PHP provides some built in constants for you. For example __FILE__ returns the name of the file that PHP is using. __LINE__ returns the line number that php is running and PHP_VERSION returns what php version your script is being run on.

Data types
Different types of data will take up different amounts of memory and may then be treated different in the script that you write. PHP will automatically determine the data type for the variable the time data is assigned to it. Some examples of data types are boolean, integer, float, string, object, array, resource, null (an uninitialized value).

The Assignment operator
The equals sign (=) is an assignment operator and will put the value on the right hand site and assign it to the left hand side.

Arithmetic Operators
Arithmetic operators perform mathematic operations on the values you want them to (providing they are a number). Some examples are addition (+), subtraction (-), division (/), multiplication (*), modulus (%). You can increment numbers by putting two addition operators nxet to eachother like so: (++). PHP provides combined operators which allow you to transform the left hand operand and return a result, while also modifying the original value of the variable. To return 'x' and and 5 to 'x' on the same line you would use '$x +=5.'

The Concatanation Operator
The concatanation operator allows you to join strings together. It is represented by a single period (.). Expressions, calculations and variables can also be concataned and the data type returned will aloways be that of a string.

The Comparison Operator
Comparison operators perform comparative tests using their operands and return the boolean value true if the test is succesful and false if it false. Some examples are Equivalence (==), Non-equivalence (!=), greater than (>), less than or equal to (<=). You can use logical operators such as Or (||), and (&&) and Not (!) to extend comparisons using the if() statement.


  • At Saturday, January 30, 2010 , Anonymous Anonymous said...

    I am the sort of guy who passions to try unused things. Presently I am making my private photovoltaic panels. I am making it all alone without the aid of my staff. I am using the net as the only path to acheive this. I encountered a really awesome site that explains how to create solar panels and wind generators. The internet site explains all the steps needed for solar panel construction.

    I'm not exactly sure bout how correct the information given there iz. If some people over here who have experience with these works can have a look and give your feedback in the site it will be awesome and I'd extremely treasure it, cauze I truly like [URL=http://solar-panel-construction.com]solar panel construction[/URL].

    Tnx for reading this. U people are the best.

  • At Wednesday, March 20, 2013 , Anonymous Anonymous said...

    Stretch marks are formed when fibroblasts are somehow restricted and skin vitality is not ok.
    There are cellulite creams made with natural ingredients that
    stimulate the skin and reduce water retention beneath the skin.

    The device utilizes a cutting-edge laser fiber that delivers laser energy to melt the fat deposits, while also thermally subscising the tissue bands.

    Stop by my web site: ways to get rid of cellulite exercises

  • At Tuesday, May 07, 2013 , Anonymous Anonymous said...

    An impressive share! I've just forwarded this onto a colleague who had been conducting a little research on this. And he in fact bought me breakfast because I stumbled upon it for him... lol. So allow me to reword this.... Thanks for the meal!! But yeah, thanx for spending some time to talk about this topic here on your internet site.

    Also visit my site :: openbox s10 hd wifi


Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home