开发者

how can i use from methods in other pages?

开发者 https://www.devze.com 2023-03-09 19:13 出处:网络
HI, i have 2 php pages.first page has some functions like Connect(),... .i wa开发者_StackOverflow社区nt to use from Connect() function in second page but when use from Connect() can not recognize it.i

HI, i have 2 php pages.first page has some functions like Connect(),... .i wa开发者_StackOverflow社区nt to use from Connect() function in second page but when use from Connect() can not recognize it.i use from header("first.php") but have same error. how can i solve that problem?


You need to include the PHP file which contains your function(s).

In this case, if you're "index" page is called index.php and your function, Connect() is stored in functions.php then you would do:

index.php:

include "functions.php";
Connect();


Create a class contains that method and include in the page where u want


You don't tell us which error you get.

A solution would be to put all the functions you want to share in their own file, e.g. functions.php and then use require in both files to have access to those functions:

require 'functions.php';
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号