我的网站的索引文件
localhost-->mywebsite-->index.php
(这是我的外部脚本)
我已经用codeigniter建立了一个注册表。
我可以使用网址http://localhost/codeigniter/index.php/form来使用注册表单。
但是我如何将该注册表格附加到我的网站索引文件中。
在我的外部php脚本(我网站的include_once"../codeigniter/index.php/form";
)中使用index.php
无效。
但是如果我将'form'
作为默认控制器文件并使用外部php脚本中的以下代码
include_once "codeigniter/index.php";
效果很好。但如果我需要其他控制器文件而不只是'form'
呢?
更新
我还可以从外部php脚本链接到该文件:
<a href="codeigniter/index.php/form>Register</a>.
但不包括在内。每当我包含它时,都不显示这样的文件。
答案 0 :(得分:3)
所以,如果我理解你正确你想在其他一些php网站上使用codeigniter's
表单,那么实际上想要做的就是错误(因为你通常无法控制你的表单行动链接等更好地直接在其他网站上建立相同的),但你的问题的答案是跟随技巧
将此代码放在您希望包含codeigniter表单的其他网站
中$output = shell_exec('php ABSOLUTE_PATH/codeigniter/index.php form index');
// where "ABSOLUTE_PATH" is absolute path to your codeigniter project
// "form" is your controller name
// "index" action name
echo $output; // will echo form html generated by codeigniter
答案 1 :(得分:2)
在localhost - &gt; mywebsite - &gt; index.php中,你可以试试这个:
<?php include_once('/codeigniter/index.php/form'); ?>
如果没有,您可以将index.php代码移动到codeigniter视图中并以此方式进行设置。
答案 2 :(得分:2)
尝试使用以下代码...
<?php $data = file_get_contents("http://localhost/codeigniter/index.php/form/");
$html_encoded = htmlentities($data);
echo $html_encoded;
?>
在上面的代码中,我们获取了$data
变量中网址的所有内容,然后对其使用 htmlentities 进行html编码......