Voting

: zero minus zero?
(Example: nine)

The Note You're Voting On

Taai
12 years ago
I discovered an interesting thing. The class name string must be accessed directly from "flat" variable. Late static binding code that get's it's variable from array that is passed by class instance, throws an syntax error. Bug?

<?php
class A {

public
$metadata = array('class' => 'A');

public static function
numbers()
{
return
123;
}

}

$instance = new A();

// This throws an error
// Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)
var_dump( $instance->metadata['class']::numbers() );

// Get the class name and store it in "flat" variable and now it's ok
$class_name = $instance->metadata['class'];
var_dump( $class_name::numbers() );

// Other tests -------------------------------------------

$arr = array('class' => 'A');

// This works too.
var_dump( $arr['class']::numbers() );
?>

<< Back to user notes page

To Top