2017-03-07 126 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線)

相關問題