Search code examples
phplaravelreferencestatic-methods

Quick fix to $this can not be used in static methods?


is there any quick fix to this? I'm not a PHP developer so it's a bit hard to fix it myself neither can I afford a developer... but I'd appreciate any help Thanks.

$this can not be used in static methods.

                 { 
                    $node = $dom->createElement($key);
                    if ($value != NULL) 
                    {
                        foreach ($value as $key => $value) 
                        {
                            $sub = $this->createNode($key, $value);
                            if ($sub != NULL)
                            {
                                $node->appendChild($sub);
                            }    
                        }
                    }
                }

imgur.com/SYAHz.png


Solution

  • try

                     { 
                        $node = $dom->createElement($key);
                        if ($value != NULL) 
                        {
                            foreach ($value as $key => $value) 
                            {
                                $sub = $dom->createNode($key, $value);
                                if ($sub != NULL)
                                {
                                    $node->appendChild($sub);
                                }    
                            }
                        }
                    }