class a {
public $a = "yay!";
func call_b()
{
b::b();
}
}
class b {
function b()
{
echo $this->a;
}
}
$a= new a();
$a->call_b();
Prints:
yay!
This is because if you statically call a method that is not declared as static in PHP, it inherits the class scope of the caller. Note that if you had declared function b as a static method, you'd get a different behavior.
Friday, February 27, 2009
Wednesday, February 25, 2009
Apple Wireless Keyboard + Ubuntu Intrepid
I had some trouble pairing at first, but found this to work:
- Turn keyboard off
- Open up the new bluetooth device wizard
- Turn the on
- Select the keyboard
- Click Next
- While the wizard is waiting, enter 0000 and Enter on the keyboard
- Enter 0000 and Enter a second time.
Tuesday, February 10, 2009
Fun with implict type conversions in PHP
PHP requires extreme care while programming. For example:
'1,234' * 1 == 1
0 == false
false == ''
0 == '0'
false != '0'
'1,234' * 1 == 1
0 == false
false == ''
0 == '0'
false != '0'
Subscribe to:
Posts (Atom)