Self-written functions

Ask questions here, report about problems.
Post Reply
KimmoFrye
Posts: 5
Joined: Tue Oct 01, 2019 9:16 pm

Self-written functions

Post by KimmoFrye » Tue Oct 08, 2019 7:41 am

I need to write a function that repeats some actions many times. I wrote a function and call it but the program return that can't call the classes of the program from my function. How it solve?

kojon
Posts: 15
Joined: Mon Mar 25, 2019 7:53 pm

Re: Self-written functions

Post by kojon » Tue Oct 08, 2019 10:04 am

You need to define a global variable in your function.

Code: Select all

// check page 404
function check_page_404($str)
{
   global $error_404,$webpage,$path_bad_links,$textfile;

   if(!strpos($webpage->get_body(),$error_404))
      return false;
   
   // add link to file with bad links
   $textfile->add_string_to_file($path_bad_links,trim($str)."
",60) ;
     
  return true;
}

https://www.php.net/manual/en/language. ... .scope.php

KimmoFrye
Posts: 5
Joined: Tue Oct 01, 2019 9:16 pm

Re: Self-written functions

Post by KimmoFrye » Tue Oct 08, 2019 12:43 pm

Thanks for your help.

Post Reply