草庐IT

set_number

全部标签

即使在设置 date_default_timezone_set 之后,PHPExcel 也会得到错误的时区

我正在使用http://phpexcel.codeplex.com在我的一个项目中,我遇到了一个问题。我想在单元格中写入time()值,我正在这样做:functionwriteTimeLine($objActiveSheet,&$lineNumber,$timeStart,$timeEnd,$duration,$category,$client,$date,$comment){$objActiveSheet->setCellValue('A'.$lineNumber,PHPExcel_Shared_Date::PHPToExcel($timeStart));$objActiveShee

php - 如何将 PHP 的 __get() 和 __set() 用于我的类中定义的字段?

我很好地阅读了PHPspecsonoverloading,并且大多数示例似乎旨在简单地允许定义自定义字段(类似于stdClass)。但是我的类中定义的私有(private)字段呢?应该如何检索/分配这些?我可以切换可能的值并对某些值采取行动:classA{private$name;private$age;publicfunction__get($var){switch($var){case'name':return$this->name;break;case'age':return$this->age+10;//justtodosomethingdifferent;)break;def

php - set_select() 辅助函数不起作用

我使用了如下代码,selectcurrency>AED>SAR>MAD>TRY但不幸的是,在表单验证失败后它没有显示选定的值。为什么这个基本的set_select()方法不起作用?我在其他一些领域使用过它并且一切正常 最佳答案 在使用set_value()、set_select()、set_checkbox()、set_radio()之前,你即使不需要/验证,也必须将这些字段传递给验证。 关于php-set_select()辅助函数不起作用,我们在StackOverflow上找到一个类似

PHP 魔术方法 __set 和 __get

这样做会被认为是好的做法吗...我的A类具有以下定义:classA{private$_varOne;private$_varTwo;private$_varThree;public$varOne;publicfunction__get($name){$fn_name='get'.$name;if(method_exists($this,$fn_name)){return$this->$fn_name();}elseif(property_exists('DB',$name)){return$this->$name;}else{returnnull;}}publicfunction__s

php - 使用 mysql_set_charset ('utf8' ) 函数后用 UTF-8 替换字符

我将所有mysql表转换为utf-8_unicode并开始使用mysql_set_charset('utf8');函数。但在此之后,一些字符如Ş、Ö开始看起来像Ö、Åž如何将mysql中的这种字母替换为UTF-8格式?很快,我能找到所有这些字符的列表来替换吗?编辑:他实际上在这篇文章中解释了这个问题,但我实际上无法正确理解它,哈哈http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html 最佳答案 你不需要那样做。只需在数据库连

PHP session.cookie_secure : Disables sessions when set to true

当我设置以下配置时:ini_set("session.cookie_secure",1);我的整个应用程序的session已禁用,我无法再写入或读取session变量。$sessionName="us";session_name($sessionName);ini_set('session.cookie_httponly',1);ini_set('session.entropy_file','/dev/urandom');ini_set('session.hash_function','whirlpool');ini_set('session.use_only_cookies',1);

php - 防止 number_format 舍入数字 - 添加逗号并保留小数点 - PHP

数字格式添加我想要的逗号但删除小数点。echonumber_format("1000000.25");返回1,000,000我希望它返回1,000,000.25我需要逗号和小数,没有任何数字舍入。我所有的值都是小数。它们的长度各不相同。我必须使用数字格式以外的格式吗? 最佳答案 如果您所说的它们的长度不同与小数部分有关,请看一下这段代码:functiongetLen($var){$tmp=explode('.',$var);if(count($tmp)>1){returnstrlen($tmp[1]);}}$var='1000000

php - 给出警告 : number_format() expects parameter 1 to be double, 字符串

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭7年前。Improvethisquestion我的页面slider出现此错误:Warning:number_format()expectsparameter1tobedouble,stringgivenin/home/globalar/public_html/wp-content/themes/au

php - ini_set() 总是返回 false

在我当前的项目中,我有一个security.php,其中包含一些函数和一些ini_set()语句。ini_set('session.use_trans_sid',0);ini_set('session.use_only_cookies',1);ini_set('session.cookie_secure',1);ini_set('session.hash_function','whirlpool');ini_set('session.cookie_httponly',1);ini_set('session.hash_bits_per_character','5');所以这是我的问题。如

php - Yii 框架 : how to set default User Roles

我已经阅读了Yii关于“基于角色的访问控制”的文档,但我没有找到在哪里配置默认用户角色。我已经添加:'authManager'=>array('class'=>'CDbAuthManager','connectionID'=>'db','defaultRoles'=>array('guest','authenticated','admin'),),到protected/config/main.php但是我必须将这些业务规则放在哪里?$bizRule='return!Yii::app()->user->isGuest;';$auth->createRole('authenticated'