Jump to content

How does these functions work?


Biske94

Recommended Posts

Hi people! Since I couldnt get answers from Stackoverflow I desiced to ask you.

Can someone explain how does these 2 functions work:

  1. class_exists()
  2. spl_autoload_register()

     

Class exist function

if(class_exists('User')){
	echo "It does exists";
}
class User {
	/*
		Some code here
	*/
}

// the output of file is "It does exists"

So how does this function works? Scans whole file? Whole directory? I mean its called before I defined class.

Spl autoload register function

include 'functions.php'; // <- file where is the function class_exist('User') and spl_autoload_register()
include 'db_config.php';
include 'database.php';
include 'user.php'; // <- Here is the class (User) 

So how does this function work? Its before any of those files that are included, and still it does it work? Does it scans whole directory where it is or what? I am really confused.

Thanks peeps!

Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...