Overview
KB
Learn PHP
PHP techniques
PHP basics
PHP Tutorial
PHP History
Command Line PHP
PHP Syntax
PHP Variables
PHP Superglobals
PHP Strings

PHP Variables

Weakly Typed Language

PHP is a weakly typed language, meaning that a variable's type can be changed on the fly. This is perfectly acceptable:
$var = 234; 
$var = 'string';
PHP, as needed, will also change a variable's type. This normally occurs when a variable of one type is provided to a function that expects data of a different type. It also happens when using some operators with variables. Although it is a convenience that PHP will convert a variable's type as needed, you should be careful about relying upon this feature too much. Conversions between strings and numbers normally work as would be expected, but conversions among the other types--arrays and objects, for example--likely have meaningless results. The PHP manual covers all of the effects and implications of type conversion in detail. To force type conversion in your code, use type casting.

Article continues:  <<previous page

 Download NuSphere PHP IDE

Download a free trial of the fast PHP EDitor and robust Integrated Development Environment for PHP.

 Buy NuSphere PhpED® now

Best PHP Editor and complete PHP IDE.
NuSphere PhpED 21.0 is available from our online store front.

 Special Team4 Offer

Get 4 copies of PhpED for the price of 3!

Optimum solution for development teams.
PhpED 21.0 Team4
Need more than 4 licenses? Contact Us for more quantity discounts, please use "Ordering/Payment issue" subject on the form.
"To be honest its bloody awesome, I have looked at loads of PHP editors and this is THE only one that actual works straight out of the box!!! Brilliant, well done."
Andrew Breward,
Director of Technology
caboodal.com