With a static property or function I don't need to make a new instance, then, can I read a static variable out of the class? In my exemplo, the variable do not return any value.
<?php //person.class.php
Class Person{
static $name;
static function setName($new_name){
self::$name = $new_name;
}
}
?>
<html> <!--index.html-->
<form action="add_name.php" method="post">
<input type="text" name="name"></input>
<input type="submit">
</form>
</html>
<?php //add_name.php
require("person.class.php");
$name = $_POST["name"];
Person::setName($name);
echo(Person::$name." now is on static property name. <a href='show.php'>See the name</a>");
?>
<?php //show.php
require("person.class.php");
echo("The name is:".Person::$name); //return empty :(
?>
I send a value to a static property on class person and I call the static property on show.php and the result is empty.