[英]running a PHP external file within a script via an if statement
I want to run an external script, within the current script (for tidyness purposes) based on a series of if and else if statements. 我想在一系列基于if和else if语句的当前脚本内(出于整洁的目的)运行一个外部脚本。
Essentialyl what I want do is this... Essentialyl我想要做的是这个...
if ($business_type == "Restaurant"); {require 'scripts/php/insert.php'}
else if ($business_type == "Hotel"); {require 'scripts/php/insert-hotel.php'}
Is this i the right way to call this external script? 这是调用此外部脚本的正确方法吗?
That is the proper way of calling the scripts, but your syntax is just a little off :) 这是调用脚本的正确方法,但是您的语法略有不足:)
if ($business_type == "Restaurant"){
require 'scripts/php/insert.php';
}
else if ($business_type == "Hotel"){
require 'scripts/php/insert-hotel.php';
}
You might want to look into the documentation for Require and Include, but require is perfectly fine for what you're doing here. 您可能需要查看Require和Include的文档,但是require非常适合您在此处所做的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.