Jump to content

Recommended Posts

That will give us whether the function exists.  He's asking for whether the function has been called.

 

<?php

function foo_called()
{
  // if foo has been called return true, else false
}

function foo()
{
  // do nothing
}

foo_called(); // false
foo();
foo_called(); // true

?>

 

What the situation is is that this is a class function: $class->function()

 

I want to check in my config file if that has been called on the current page, and if it hasn't been called then I want to return an error.. But if it has been called then no error shall be shown and the page will continue. My config file is required in every page so it should check in every page.. however it is required before all the content..

 

And how does that work MmmVomit.. you have nothing in the functions :S

My code was just to demonstrate what you meant to mgallforever.  It's completely non-functional.

 

If the function is in a class, set a private member variable within the class from within the function.  I don't know the syntax for class very well, but it would look something like this.

 

<?php
class foo
{
  private $init_called = false;

  function init()
  {
    $init_called = true;
  
    \\ do more stuff
  }

  function initialized()
  {
    return $init_called;
  }
}
?>

 

Again, I don't really use classes very much in PHP, so that syntax probably has tons of errors.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.