Yii框架类似POST和GET的功能
任何人都可以将此代码转换为 yii 框架吗?
文件名:text.php
<form method='POST' action='index.php'>
<input type='text' name='name'>
<input type='submit' value='SUBMIT'>
</form>
那么text中的文字就会在索引中查看。
文件名:index.php
$text=$_POST['name'];
echo "$text";
谁能在 Yii 中实现这段代码?以及用于使用 GET 方法的代码是什么,假设index.php将是控制器,text.php将是视图文件
(我在这里试图实现的是传递名为的文本框的值控制器的“名称”)?
有人可以帮忙吗?
can anyone convert this code into the yii framework?
file name: text.php
<form method='POST' action='index.php'>
<input type='text' name='name'>
<input type='submit' value='SUBMIT'>
</form>
then the text in the text will be viewed in the index.
file name: index.php
$text=$_POST['name'];
echo "$text";
Can anyone implement this code in Yii? and what is also the code used for using GET method , assuming that the index.php will be the controller and the text.php will be the view file
(what i am trying to achieve here is to pass the value of the textbox named as 'name' to the controller)?
can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Yii 表单生成:
Yii CHtml docs
此外,您还需要实现 CModel 或 CForm 类来验证形式。
Yii form generation:
Yii CHtml docs
Also you need implement CModel or CForm class to validate form.
您必须在控制器中使用
$_POST['name']
来获取该值,就像您所做的那样。如果您使用 GET 方法来执行此操作,它宁愿是控制器中方法的参数:
You have to use
$_POST['name']
in your controller to get the value, just like you did it.If you do it with the GET method, it would rather be a parameter of a method in your controller: