<?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

    Welcome to PHPBuilder!

    First problem I see is that your code snippet appears to have suffered from a mangled copy-paste; it's almost as if you've got pieces of at least three different revisions/sections of a script all mashed into a single code snippet.

    So, you might want to post a new code snippet before we even look at it.

      I see what you are talking about. I do not know what to do. I have treid to delete it but that's no. I can not find no edit. HELP

        Like he said, just POST a new snippet. As a new member you cannot edit your posts (yet). You can never delete your own posts unless you are a moderator.

          One problem I do notice now (which, again, I can't be sure is an actual problem since it would appear we don't know exactly what the state of your code is) is here:

          public function __call($methodName, $argments) {

          You define an argument called $argments, however you later reference a variable called $arguments - perhaps the former is a typo/misspelling?

            That was it. The misspelling of argument. Thanks I overlooked that for two days now. Big Thanks

              larka06;11038733 wrote:

              I overlooked that for two days now.

              Were you ignoring the error message:

              Warning: array_unshift() expects parameter 1 to be array, null given in (file) on line (number)

              ?

                Write a Reply...