是否可以使用PHP识别Linux 32或64位?
phpinfo()
Run Code Online (Sandbox Code Playgroud)
回报
Linux infong 2.4 #1 SMP Mon Oct 10 09:34:36 UTC 2011 i686 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
它是共享主机,所以我不能使用命令行.
我有这样的活动:
package com.nkdroid.daynighttheme;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.widget.TextView;
public class ModeActivity extends AppCompatActivity {
private TextView txtModeType;
int modeType;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_mode);
txtModeType = (TextView) findViewById(R.id.txtModeType);
modeType = AppCompatDelegate.getDefaultNightMode();
if (modeType == AppCompatDelegate.MODE_NIGHT_AUTO) {
txtModeType.setText("Default Mode: Auto");
} else if (modeType == AppCompatDelegate.MODE_NIGHT_YES) {
txtModeType.setText("Default Mode: Night");
} else if (modeType == AppCompatDelegate.MODE_NIGHT_NO) {
txtModeType.setText("Default Mode: Day");
}
}
}`
Run Code Online (Sandbox Code Playgroud)
如果默认模式设置为AUTO,是否可以获得当前激活的模式(白天或夜晚)?
这个查询工作并返回我想要在MySQL中的结果但是如何让它在wordpress中工作?
SELECT * FROM `wp_usermeta` WHERE `meta_key` = 'points' AND `user_id` = '1'
Run Code Online (Sandbox Code Playgroud)
我希望能够看到用户1获得的所有"积分".我需要能够在wordpress的帖子和页面上显示这一点.
我有与此类似的字符串:
{{something1}} something2 {{something3}} something4
Run Code Online (Sandbox Code Playgroud)
如何使用该preg_match()功能仅匹配"something1" ?
我试过了:
preg_match("/\{\{(.*)\}\}/si",$content,$matches);
Run Code Online (Sandbox Code Playgroud)
但是这个匹配太多了,回来了
something1}} something2 {{something3
Run Code Online (Sandbox Code Playgroud)
我尝试添加\b到模式,但也没有得到我想要的那样.
你能帮帮我吗?
我知道年份和年份(0-365).有没有办法从它回到时间戳?
就像是:
$day=date('z');
$year=2012;
$timestamp=strtotime($day.'-nd day of '.$year);
Run Code Online (Sandbox Code Playgroud) 我有Yii应用程序和两个具有相同结构的表tbl和tbl_history:
现在想要创建模型,因此它将在调用模型时通过我发送的参数选择表.例如:
MyModel::model('tbl')->find();
//and
MyModel::model('tbl_history')->find();
Run Code Online (Sandbox Code Playgroud)
在Yii论坛中找到解决方案的相关文章.做了相同的更改,最后在MyModel中得到了这个:
private $tableName = 'tbl'; // <=default value
private static $_models=array();
private $_md;
public static function model($tableName = false, $className=__CLASS__)
{
if($tableName === null) $className=null; // this string will save internal CActiveRecord functionality
if(!$tableName)
return parent::model($className);
if(isset(self::$_models[$tableName.$className]))
return self::$_models[$tableName.$className];
else
{
$model=self::$_models[$tableName.$className]=new $className(null);
$model->tableName = $tableName;
$model->_md=new CActiveRecordMetaData($model);
$model->attachBehaviors($model->behaviors());
return $model;
}
}
Run Code Online (Sandbox Code Playgroud)
现在当我做:
echo MyModel::model('tbl_history')->tableName(); // Output: tbl_history
Run Code Online (Sandbox Code Playgroud)
它返回正确的值,但是:
MyModel::model('tbl_history')->find();
Run Code Online (Sandbox Code Playgroud)
仍然返回tbl的值.
添加: …
我在services.xml中有服务
<service id="my.connection" class="Doctrine\Bundle\DoctrineBundle\ConnectionFactory">
</service>
<service id="my.main" class="%my.main.class%">
<call method="foo">
<argument type="service" id="tmcyc.connection" />
</call>
</service>
Run Code Online (Sandbox Code Playgroud)
但得到错误:
可捕获的致命错误:传递给Doctrine\Bundle\DoctrineBundle\ConnectionFactory :: __ construct()的参数1必须是一个数组,没有给出...
如何通过参数传递数组?例如:
<service id="my.connection" class="Doctrine\Bundle\DoctrineBundle\ConnectionFactory">
<argument>[ARRAY]</argument>
</service>
Run Code Online (Sandbox Code Playgroud)
或者我做错了什么?因为这段代码很有用:
$connectionFactory = $this->getContainer()->get('doctrine.dbal.connection_factory');
$conn = $this->createConnection($this->conn);
$conn->executeQuery('SET NAMES utf8');
Run Code Online (Sandbox Code Playgroud) 例如,我们有表:
CREATE TABLE `my_tbl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_type` int(11) NOT NULL,
`date` date NOT NULL,
`other_fields` varchar(200) CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`id`),
KEY `id_type` (`id_type`),
KEY `type_date` (`id_type`,`date`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Run Code Online (Sandbox Code Playgroud)
Ther是两个索引:id_type和id_type,date.
据我所知,如果我们有两个字段的索引,我们可以将它用作第一个字段的单个索引.
我可以删除索引id_type而不会丢失性能吗?
更新:问这个问题引起注意,有时不同索引中的同一个字段具有不同的基数.
我有字符串:
FirstWord word2 word3 wrongWord word4 lastWord
想要选择字符串开头FirstWord,结尾lastWord和不包含wrongWord.
我有第一个也是最后一个:
/ firstword(.*?)lastword/i
但排除wrongword不起作用.
尝试:
/ firstword(^ wrongWord*?)lastword/i
/ firstword ^((?! wrongWord).)*lastword/i
更像这样,但没有任何作用.
在Yii我能做到:
$model = ModelName::model();
Run Code Online (Sandbox Code Playgroud)
我可以从任何地方调用它,它将始终返回相同的实例.
那我可以决定Yii使用Singleton模式吗?
唯一的区别就是我看到的是__construct,__clone,__wakeup得不到保护.