2017-03-07 130 views
-1

我想从我的index.php中调用我的自定义php函数,但该函数位于另一个文件中。何那么做?如何从另一个文件调用php函数?

例子:

的index.php:

<?php 

myCustomFunction(); 

?> 

function.php

<?php 

function myCustomFunction(){ 
//some codes 
} 

?> 

谢谢。

回答

0

变化的index.php如下:

<?php 
    include "function.php"; 
    myCustomFunction(); 
>? 

(这是基于这样的假设两个文件都在同一个目录中,否则你必须添加的文件路径中include线)

相关问题