在Yii框架的本教程中 http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#action
我想把我的动作从一个控制器放到一个单独的动作文件中,并按照说明"创建一个Action类"
这是我的动作类文件
class LoginAction extends CAction
{
private $contents = array();
public function run(){
$loginmodel = new LoginForm;
//answer ajax validating request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form'){
echo CActiveForm::validate($loginmodel);
Yii::app()->end();
}
//collect user input data to do login
if(isset($_POST["LoginForm"]))
{
$loginmodel->attributes = $_POST["LoginForm"];
// validate user input and redirect to the previous page if valid
if($loginmodel->validate() && $loginmodel->login()){ //<--invoking here the login and validate function
$this->redirect(Yii::app()->user->returnUrl);
}
}
$this->contents["loginmodel"] = $loginmodel;
$this->render('index',$this->contents);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中
class SandboxController extends Controller{
public …Run Code Online (Sandbox Code Playgroud) 好吧,我有以下代码
$from = "Asia/Manila";
$to = "UTC";
$org_time = new DateTime("2012-05-15 10:50:00");
$org_time = $org_time->format("Y-m-d H:i:s");
$conv_time = NULL;
$userTimezone = new DateTimeZone($from);
$gmtTimezone = new DateTimeZone($to);
$myDateTime = new DateTime($org_time, $gmtTimezone);
$offset = $userTimezone->getOffset($myDateTime);
$conv_time = date('Y-m-d H:i:s', $myDateTime->format('U') + $offset);
echo $conv_time;
Run Code Online (Sandbox Code Playgroud)
使用此代码我想转换2012-05-15 10:50:00为UTC和-8时区(我使用美国/温哥华),但它给了我一个奇怪的结果
Run Code Online (Sandbox Code Playgroud)Asia/Manila > UTC 2012-05-15 19:50:00 = the correct is 2012-05-15 02:50
而对于美国/温哥华
Asia/Manila > America/Vancouver
2012-05-16 02:50:00 = the correct is 2012-05-14 19:50
Run Code Online (Sandbox Code Playgroud)
哪里出错了?
我正在尝试将数据从表单发送到php文件,因此我可以将其存储在数据库中,但它无法正常工作...
表单的代码与php文件不在同一服务器上,因为表单将在移动应用程序上.
HTML
<div data-role="page" id="createclub">
<div data-role="content">
<form id="cname" align="left" action="post">
<label for="name">Enter Name:</label>
<input type="text" id="name" value="" />
<input type="submit" value="Submit" data-inline="true">
</form>
<div id="result"></div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("#cname").submit( function () {
$.post(
'http://www.clubbedin.isadcharity.org/createclub.php',
$("#cname").serialize(),
function(data){
$("#result").html(data);
alert("Data " + data);
}
);
return false;
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
php文件
$name = $_POST['name'];
Run Code Online (Sandbox Code Playgroud)
谢谢!!!
我在下面有以下代码
Map<String, Integer> buyingItemEnumerationMap = this.toBuyItemEnumeration;
for (Entry<String, Integer> item : buyingItemEnumerationMap.entrySet()) {
if(RandomEngine.boolChance(50)){ //will delete?
buyingItemEnumerationMap.remove(item.getKey());
}
if(buyingItemEnumerationMap.size() == 1){
break;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我正在使用Android游戏,上面的代码以多线程方式运行.现在我有一个例外java.util.ConcurrentModificationException.我已经研究过如何解决这个问题,但似乎没有对我有所帮助.我在上面的代码上做的是随机删除一个条目.我怎样才能在那里实现它?
arraylists,缓冲读卡器,扫描仪等.语言中"已经存在"的所有"默认"类.
不像公共类的widthOfTable,它是一个"组成"的类,"在语言中不存在".
教学时为什么没有用来区分这些想法的术语?尽管在这里已经3年了,但我在大学里几乎没有发现这种差异.
在PHP中,如何检查String是否只包含字母?我想写一个if语句,如果有(空格,数字,符号)或除了a-z和之外的任何其他内容,将返回false A-Z.
我的字符串必须只包含字母.
我以为我可以这样做,但我做错了:
if( ereg("[a-zA-Z]+", $myString))
return true;
else
return false;
Run Code Online (Sandbox Code Playgroud)
如何确定是否myString只包含字母?
我想获得我的Yii框架项目使用的当前主题的名称.
我曾尝试过以下代码,但没有成功
Yii::app()->getTheme();
Yii::app()->theme;
Run Code Online (Sandbox Code Playgroud)
什么是将返回我的Yii项目当前使用的当前主题名称的代码?
谢谢
好的,我有一个选择框
<select id="txtPriority" style="color:#008000;">
<option value="0" style="color:#0000FF;">Low</option>
<option value="1" selected="selected" style="color:#008000;">Normal</option>
<option value="2" style="color:#B22222;">Critical</option>
</select>
Run Code Online (Sandbox Code Playgroud)
现在与该选择框,我想创建一个按钮,单击时将选择框的选择项返回到<option>有selected="selected".现在可以使用简单的jQuery代码吗?
好的,我确实有下面的代码
<?php
class foo{
public $bar = NULL;
public function boo(){
$this->bar();
}
}
$mee = new foo();
//save a closure function on the property
$mee->bar = function(){
echo 'hahaha';
};
//invoke the closure function by using a class method
$mee->boo();
?>
Run Code Online (Sandbox Code Playgroud)
你可以看到它在这里运行http://codepad.org/s1jhi7cv
现在我想要的是将闭包函数存储在类方法中.
井盖是可能的,因为我在这里阅读有关它的文档http://php.net/manual/en/functions.anonymous.php
这可能吗?我做错了吗?请纠正我
我真的想要实现这样的东西.
myVar.myAnotherVar;
myVar.myMethod();
myVar("sample text");
Run Code Online (Sandbox Code Playgroud)
这就是jQuery实现它的方式
jQuery.fn;
jQuery.ajax();
jQuery("#myBtn");
Run Code Online (Sandbox Code Playgroud)
我如何实现像jQuery这样的东西在一个命名空间中保存一切?它与原型有关吗?如何使用变量同时作为函数调用?
谢谢 :)