我想在当前脚本中运行一个外部脚本(为了整洁),基于一系列if和else if语句。
本质 我想做的是这个...
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';
}
您可能需要查看"要求"和"包含"的文档,但"要求"对于您在此处执行的操作完全没问题。