Differences in PHP language support

A summary of the differences in the PHP language support provided in IBM® WebSphere® sMash compared to the PHP runtime available from http://php.net. Any notes or differences for individual PHP functions are documented in the list of Core PHP functions

There are some differences between the behavior of the PHP language support provided in WebSphere sMash and the behavior of running a PHP script on the PHP runtime available from http://php.net

Description Behavior on php.net Behavior in WebSphere sMash Notes
Notice on array to string conversion Behavior is inconsistent (5.2.1). Always outputs notice.
iconv behavior on AIX php.net linux platforms use the system iconv library, which contains encodings such as UCS-4BE and UCS-4LE p8 uses the same encodings on linux, but the iconv library on AIX has different encoding names. There are mappings to allow ASCII, UTF-8, SJIS, EUC-JP, EUC-TW, EUC-CN and EUC-KR, but the UCS styles do not exist, you have to use 'uucode' instead
Modifying array during foreach loop while using &$value syntax Behaviour is inconsistent (5.2.1). Changes to array reflect upon $value.
Expansion of complex variables inside strings $a[0] expands to the value of $a[0], but $a[0][0] expands to Array[0]. Expands to the value of the variable in both cases.
Parsing invalid UTF-8 strings
htmlentities("Le CafΘ< CafΘ <");.
Ignores just the first xE9 character (e acute in cp1252). Both xE9 character are ignored.
var_dump of array containing a reference to a value, where there are no longer any other references to that value.
array(1) {
  [0]=>
  &int(123456789)
}
	

(note the ampersand)

array(1) {
  [0]=>
  int(123456789)
}
	
This is a trivial example of a consequence of a garbage-collection model over reference counting. Reference counting here allows php.net to demote a reference to a value when its reference count falls to one, whereas WebSphere sMash has no way of knowing that there is only one reference to the value. This also affects backtrace dumps from Exception objects.
Difference in object handle from var_dump.
object(stdClass)#1 (1) {
        ["a"]=>
        int(0)
}
	
object(stdClass)#2 (1) {
        ["a"]=>
        int(0)
}
	
Each object has a handle/ID which is exposed by var_dump($object) after the #. sign. WebSphere sMash cannot guarantee to use the same ID as php.net, where this ID is derived from the way the object is allocated in memory.
Using __FUNCTION__ within an include within a function delaration. __FUNCTION__ evaluates to "" (5.2.1). __FUNCTION__ evaluates to the name of the declaring function. php.net's behaviour contradicts the manual entry for include:
If the include occurs inside a function within the calling file, then all of the code contained in the called file will behave as though it had been defined inside that function.
Superglobals, ampersands, var_dump and $GLOBALS. Superglobals are not preceded by & in $GLOBALS (they arenot shown as references) (5.2.1). Superglobals are preceded by & in $GLOBALS (they are shown as references) WebSphere sMash handles superglobals by injecting references to them at all scopes, including global scope. Therefore, superglobals are shown as references in $GLOBALS.
Strict warnings when implicitly initialising objects. $obj->b=1; emits a strict warning but $obj->b[0]=1; does not (5.2.3). Both $obj->b=1; and $obj->b[0]=1; emit a strict warning. $obj->b=X and $obj->b[0]=X both implicitly initialise $obj to an instance of stdClass, but in php.net only the first emits the warning: Strict Standards: Creating default object from empty value.
Reference counts off by one. $a=array(1);
Reference count of element will be one.
The reference count will be two. This happens because a variable in WebSphere sMash is created in the data section of the script and has an initial reference count of one. When this is assigned into an array, the reference count is incremented to two.
WebSphere sMash does not support short tags and <script> tags.
Parse error messages will include language construct not token names. Parse error: syntax error, unexpected T_FOR in <testcase path> on line 3 Parse error: syntax error, unexpected 'for' in <testcase path> on line 3
php.ini is read using the Java platform encoding.
property_exists behaviour. php.net 5.2 tries to respect visiblity of properties and has bugs. php.net 5.3 ignores scope and visibility. WebSphere sMash matches php.net 5.3 behaviour and matches logic for method_exists function.
Static magic methods php.net 5.3 supports __callStatic. Support for __getStatic, __setStatic and __issetStatic is also expected to be implemented before release. php.net 5.2 has no support for static magic methods. WebSphere sMash 2.0 supports all static magic methods. These magic methods allow a class to intercept static method calls and static field accesses. They complement their not static equivalents __call, __get, __set and __isset. __unset has no static equivalent since static variables cannot be unset on a class in the PHP language.
Number of entries in a PHP array An array can support 2^32 entries. That is 4,294,967,296. An array can support 2^31 - 1 entries. That is 2,147,483,647. This limit is unlikely to affect your application. Memory limits will be reached before number of array entries is reached.
The final context argument passed to a user error handler. context always present. The context parameter should contain an array of local variables from the function where the error was raised, on sMash the parameter will contain an empty array when the error was raised in an optimized function. Set map_locals=On in php.ini to have standard behaviour at a significant cost to performance.
Range of Integer values. Varies according to the platform. INT_MAX_VALUE=2,147,483,647
INT_MIN_VALUE=-2,147,483,648
On all platforms.
Integers are 32 bits.

Version 1.1.31300