[英]running a PHP external file within a script via an if statement
我想在一系列基於if和else if語句的當前腳本內(出於整潔的目的)運行一個外部腳本。
Essentialyl我想要做的是這個...
if ($business_type == "Restaurant"); {require 'scripts/php/insert.php'}
else if ($business_type == "Hotel"); {require 'scripts/php/insert-hotel.php'}
這是調用此外部腳本的正確方法嗎?
這是調用腳本的正確方法,但是您的語法略有不足:)
if ($business_type == "Restaurant"){
require 'scripts/php/insert.php';
}
else if ($business_type == "Hotel"){
require 'scripts/php/insert-hotel.php';
}
您可能需要查看Require和Include的文檔,但是require非常適合您在此處所做的事情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.