<?php
class CleverString {
private $_theString="";
private Static $_allowedFunctions=array("strlen", "strtoupper", "strpos");
public function setString($stringVal) {
$this-> _theString = $stringVal;
}
public function getString() {
return $this-> _theString;
}
public function __call($methodName, $argments) {
if (in_array($methodName, CleverString::$_allowedFunctions)) {<?php
class CleverString {
private $_theString="";
private Static $_allowedFunctions=array("strlen", "strtoupper", "strpos");
public function setString($stringVal) {
$this-> _theString = $stringVal;
}
public function getString() {
return $this-> _theString;
}
public function __call($methodName, $argments) {
if (in_array($methodName, CleverString::$_allowedFunctions)) {
array_unshift($arguments, $this-> _theString);
return call_user_func_array($methodName, $arguments);
} else {
die("<p>Method 'CleverString::$methodName' doesn't exist </p>");
}
}
}
$myString = new CleverString;
$myString-> setString("Hello!");
echo"<p>The string is: ".$myString-> getString()."</p>";
echo"<p>The length of the string is: ".$myString-> strlen()."</p>";
echo "<p>The string in uppercase letters is: ".$myString-> strtoupper()."</p>";
echo"<p>The letter e occurs at position: ".$myString-> strpos("e")."</p>";
$mystring->madeUpMethod();
?>
array_unshift($arguments, $this-> _theString);
return call_user_func_array($methodName, $arguments);
} else {
die("<p>Method 'CleverString::$methodName' doesn't exist </p>");
}
}
}
$myString = new CleverString;
$myString-> setString("Hello!");
echo"<p>The string is: ".$myString-> getString()."</p>";
echo"<p>The length of the string is: ".$myString-> strlen()."</p>";
echo "<p>The string in uppercase letters is: ".$myString-> strtoupper()."</p>";
echo"<p>The letter e occurs at position: ".$myString-> strpos("e")."</p>";
$mystring->madeUpMethod();
?>
Every place $myString is involved I get no print out. I can not find out why can someone take a look see if they can see why it doesn't work.
Thanks