Jump to content

purencool

Members
  • Posts

    161
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.purencool.com

Profile Information

  • Gender
    Male
  • Location
    Australia

purencool's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Thanks for all your feedback. I found a way that is very clean. This is the completed code it gets an array of objects finds the method that then executes it. public function getMethodForms($methodName){ foreach ($this->formsObj as $key => $Obj){ //test to see if the method exists if ((int)method_exists($Obj, $methodName) == 1){ //if it does execute $return= $Obj->{$methodName}(); } } //print_r($return); return $return; }
  2. Hi PhpFreaks, I have a method that I need to be initialised dynamically and I am not sure if the code below will work I have been able to workout if the method exists but I have not found a way to it get to return the array. Has anyone go any ideas? The error I get is: Catchable fatal error: Object of class Forms could not be converted to string public function setMethodForms($methodName){ echo $methodName." and does it exist ". (int)method_exists($this->formsObj, $methodName); //test to see if the method exists if ((int)method_exists($this->formsObj, $methodName) == 1){ //if it does execute //print_r ($this->formsObj->projects()); //test to see if object works $return call_user_func($this->formsObj."->".$methodName."()"); } return $return; }
  3. Hi php freaks I have been going through someone elses code and have seen this below. What does the & at the start of the function do? function &foo(){} Thanks
  4. thanks I don't know what I was thinking. I should of know that
  5. Hi phpfreaks, I don't know I can't seem to get the $this->updateFilename to work the first piece of code works beautifully 'version1.tar.gz' came from the copy and pasting of the echo trim($this->updateFile); the code below will not work and I can't work out why any suggestions?$this->updateFile;comes from a screen scrape that is the only thing I can think of that is different? echo trim($this->updateFile); $filename = 'version1.tar.gz'; echo "<br>". $filename." hello world<br>"; if (file_exists($filename)){ $filename = trim($this->updateFile); echo "<br>". $filename." hello world<br>"; if (file_exists($filename)){
  6. yes the example works but I must have another issue driving the error. I was just confirming that the theory was right thanks again
  7. thanks I have been testing I can't get to work what I have created a little more complicated but if the struck is right I have go back to testing thanks for your help.
  8. Thanks for the reply. Yes your right in the script I am testing I have got that but thanks for pointing it out I left it out of the example. What I am wonder can I do this $this->A->a(); in php?
  9. hi php people, I am wondering will if the code below will work when I call $C->getafoo() will I get foo; I keep getting an error at this point return $this->A->a(); saying the method is not there class A{ public function a(){ return "foo"; } } class B { public $A; function __construct($A) { $this->A = $A; } public function geta(){ return $this->A->a(); } } class C extends B{ public function getafoo(){ return geta(); } } $C = new C(new A()); echo $C->getafoo();
  10. could i use is_bool($a) in my access class to force a return of true or false?
  11. I have an issue that with some testing on an Access class with a method getControlAccess it should only return true or false but as soon as I place a string of any sort into the return my tests always returns true. Any help to point out if it is the way I am testing or the way I have written the method would be great. In the example below it would return true. In one class I have this method class Access{ public function getControlAccess(){ return 'I am stuffed'; } } In the second class I have this class AccessTests extends Access{ public function controlAccessTest(){ $return = "<ul>"; if ($this->getControlAccess() == TRUE){ $return .= "<li>getControlAcess should be true and is returning:<b> ". $this->getControlAccess() ."</b></li>"; } elseif ($this->getControlAccess() == FALSE){ $return .= "<li>getControlAcess should be false and is returning:<b> ". $this->getControlAccess() ."<b></li>"; } else { $return .= "<li>getControlAcess is really stuffed:<b>". $this->getControlAccess() ."<b></li>"; } $return .= "</ul>"; return $return; } public function setAccessTest($set){ return $set; } }
  12. Hi phpfreaks I am trying to remove the first two numbers off a string. The string looks like 00-house or 23-water etc. I need to do a regex to remove them I have this so far but it does not work. $removed = preg_replace(array("/^\d[0-9]/", $folderItem); Any help would be great.
  13. ok worked it out, RewriteRule ^([^/\.]+)/?$ index.php?p=$1 [L] but the links in the app were set to index.php?p=foo so when clicked it was displaying the link. When these were changed it work perfectly.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.