/    Sign up×
Community /Pin to ProfileBookmark

Ubuntu 8.04 converts PHP 5.2 functionnames?

Hello everyone,
I have a Ubuntu 8.04 Server running PHP Version 5.2.4-2ubuntu5.6.
Class B contains the methode Insert(). This method is called within another class A:

class A extends B {
public function Insert() {
return parent::Insert();
}
}

What I see is:
Fatal error: Call to undefined method B::insert() (!!! first letter shown in lower case !!!)

On Windows it was ok but after I transferred it to Linux, the functionname was converted to lower case letters and the function can not be called.

Has anybody an idea?

Thank you – Ch.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiMay 22.2009 — I don't think it's the parent::Insert that is causing you the problem, I think where you actually call the method on your class B object you probably use a lower case i. Windows doesn't see the difference because it is too stupid to care about case sensitivity, but Linux does. Can you post the full code?
Copy linkTweet thisAlerts:
@ChickenmanauthorMay 22.2009 — Class A is:

class Bewertung_BASE extends cls_tbl_Bewertung {

private $_main;
public $data;

public function __construct(&$main, $id = null)
{
$this->data = array( "id" => (int)$id,
"bewertung_key" => (string)"",
"aktiv" => (int)"",
"timestamp" => "");

$this -> _main = $main;

parent::__construct();
}


public function __destruct()
{

}


public function __get( $var )
{
if(array_key_exists($var,$this->data))
{
return $this->data[$var];
}
}


public function __set( $var, $val )
{
if(array_key_exists($var, $this->data))
{
$this->data[$var] = $val;
}
}


public function Update()
{
if($this->id > 0)
{
return parent::Update();
}
}


public function Insert()
{
return parent::Insert();
}


public function Delete()
{
if($this->id > 0)
{
return parent::Delete();
}
}

}



--------------------------------

Class B is:

class cls_tbl_Bewertung

{

private $_base;

public function __construct()
{
if( class_exists(__CLASS__."_BASE") )
{
$base = __CLASS__."_BASE";
$this->_base = new $base($this);
}
}

public function __destruct()
{

}


public function __call($method, $args)
{
if( method_exists($this->_base, $method) )
return call_user_func_array( array($this->_base, $method), $args );
else
trigger_error("Call to undefined method " . get_class($this->_base) . "::" . $method, E_USER_ERROR);

}


}


---------------

Thank you - Ch.
Copy linkTweet thisAlerts:
@MindzaiMay 22.2009 — Well that's not the same as what you posted first time.

[code=php]
public function Insert()
{
return parent::insert(); //<-- lower case i !!!
}
[/code]


Also please use php tags when posting code, it makes it much easier to read.
Copy linkTweet thisAlerts:
@ChickenmanauthorMay 22.2009 — Sorry, that was an edited code from copy and paste. I just edited it after seeing the error to see if it would work with lower case functionname. I corrected the code in my post. So originally the function was called parent::Insert()

Ch.
Copy linkTweet thisAlerts:
@MindzaiMay 22.2009 — OK, in that case I think it is still most likely that the code which uses objects instantiated from the cls_tbl_Bewertung class is making calls to insert() rather than Insert.
Copy linkTweet thisAlerts:
@ChickenmanauthorMay 22.2009 — Just to close this thread:

__call seems automatically to be used like __callStatic in PHP 5.3.

I found that in

http://www.phpbuilder.com/manual/en/language.oop5.overloading.php

Important is the 'Note' !

/** As of PHP 5.3.0 */

public static function __callStatic($name, $arguments) {

// Note: value of $name is converted to lower case.

echo "Calling static method '$name' "

. implode(', ', $arguments). "n";

}

}

Thanks for thinking and replying - Ch.
Copy linkTweet thisAlerts:
@MindzaiMay 22.2009 — Ah good thanks for updating with the solution.
×

Success!

Help @Chickenman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...