ארכיון עבור 2 במרץ, 2008

class SomeCaseClass {
var $samplevar;
function SomeCaseClass($samplevar) {
$this->samplevar = $samplevar;
}
}
$ClassVar = new SomeCaseClass('Sample Var');echo (get_class($holland)." "\n");

בPHP4, התוצאה תהיה

somecaseclass , לעומת זאת, חשוב לשים לב, שבPHP5, התוצאה תהיה:
SomeCaseClass.

מאת אביב רונן בPHP | אין תגובות

בPHP 4, יכולנו לבצע CASTING למשנה באופן פשוט,
לדוגמה:

class casttest {
function set_id($id) {
$this-> = $id;
}
}

$test1 = new casttest;echo (int) $test1, "\n";

התוצאה, כפי שבוודאי ניחשתם, תהיה 1 כיוון שיש ערך למה שהדפסנו.
לעומת זאת, בPHP5, התוצאה תהיה:

Notice: Object of class Country could not be converted to integer in - on line X

והערך אשר נקבל יהיה 1,
על מנת לפתור את הבעיה, ואת ההבדלים בין גירסה 4 ל5, כל שעלינו לעשות הוא להוסיף :

zend.ze1_compatibility_mode = 1

וואלה!

מאת אביב רונן בPHP | אין תגובות