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
Post a Comment