Using $this inside a static function fails
This is the correct way
public static function userNameAvailibility()
{
$result = self::getsomthin();
}
Use self::
instead of $this->
for static methods.
See: PHP Static Methods Tutorial for more info :)
You can't use $this
inside a static function, because static functions are independent of any instantiated object.
Try making the function not static.
Edit:
By definition, static methods can be called without any instantiated object, and thus there is no meaningful use of $this
inside a static method.
Only static functions can be called within the static function using self:: if your class contains non static function which you want to use then you can declare the instance of the same class and use it.
<?php
class some_class{
function nonStatic() {
//..... Some code ....
}
Static function isStatic(){
$someClassObject = new some_class;
$someClassObject->nonStatic();
}
}
?>