include - How to access data from other .php file in PHP? -


i have login.php , mainpage.php files , want access login.php's user's data mainpage.php.

should use require or include? how connect files?

require login.php; include login.php; 

best write object-oriented codes, i.e. mainpage.php would

require('login.php'); 

just definition of let's class loginform , in mainpage.php do:

$loginform = new loginform(); 

alternatively place logic functions , let mainpage.php call handlelogin() defined in login.php. in both of mentioned cases mainpage.php needs know definition of function/class, therefore should use require or require_once.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -