phpstorm 设置多项目并存 phpstorm 或 webstorm设置多个项目可以并存: File -> settings -> Directories -> Add Content Root 中添加你当前的工程目录。 from:http://www.bestphper.cn/article-46.html
View Details介绍 枚举是一个指定的常数,其基础类型可以是除 Char 外的任何整型。 如果没有显式声明基础类型,则使用 Int32。 编程语言通常提供语法来声明由一组已命名的常数和它们的值组成的枚举。 定义 默认基数从O开始,也可指定数值。 enum Days { Saturday=1, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday }; enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 }; 使用 Colors myColors = Colors.Red; string strColor=myColors.tostring(); int IntColor=(int)myColors ; 位或 Colors myColors = Colors.Red | Colors.Blue | Colors.Yellow; 位与 Colors myColors = Colors.Red & Colors.Blue & Colors.Yellow; 遍历 foreach (string s in Enum.GetNames(typeof(Days))) Response.Write(s + "--" + Enum.Parse(typeof(Days), s).ToString()); 转换 Colors mc=Colors Enum.Parse(typeof(Colors ), "red"); if (System.Enum.IsDefined(typeof(Days), "Monday")) Days ds= (Days)Enum.Parse(typeof(Days), "Monday"); 实例二: public enum NoticeType { Notice = 'A', LabRule = 'H', HotInformation = 'N', Column = 'C', All = '1', Null = '0' } //新建枚举类型 NoticeType noticeType1 = NoticeType.Column; //把枚举类型转换为string d="Column" string d = noticeType1.ToString(); //取得枚举类型的基数 dd=’C' char dd = (char)noticeType1; //通过基数取得对应的枚举类型 noticeType2 = NoticeType.Notice //(NoticeType)’A'; 两种方式都可以 NoticeType noticeType2 = (NoticeType)Char.Parse("A"); //通过名称取得枚举类型 noticeType3 = NoticeType.Notice NoticeType noticeType3 = (NoticeType)Enum.Parse(typeof(NoticeType), "Notice"); from:http://www.cnblogs.com/an-wl/archive/2011/04/14/2015815.html
View Details在Sql Server2005中,如果将某字段定义成日期 时间 类型DateTime,那么在视图中会默认显示成年月日时分秒的方式(如 2013/8/6 13:37:33) 如果只想显示成年月日形式,不要时分秒,那么该怎么办呢? 第一种方法:先设置一个时间显示的模板,然后在需要显示时间的地方调用这个模板就行了。 1、在Share文件夹下,创建一个文件夹DisplayTemplates 2、在DisplayTemplates文件夹下,创建一个视图LongDateTime.cshtml 3、在视图LongDateTime.cshtml中输入代码
|
1 2 3 |
<span class="variable">@model</span> <span class="constant">System</span>.<span class="constant">DateTime</span> <span class="variable">@Model</span>.<span class="constant">ToLongDateString</span>() |
当然,后面那句也可以换成@Model.ToShortDateString()或其它日期格式。 4、在需要显示日期的地方,由原来的
|
1 |
<span class="at_rule">@Html.<span class="function">DisplayFor(modelItem => item.PostTime)</span></span> |
替换成
|
1 |
<span class="at_rule">@Html.<span class="function">DisplayFor(modelItem => item.PostTime,<span class="string">"</span><span class="string">LongDateTime"</span>)</span></span> |
这样就完成了时间格式的显示转换。由原来的显示方式(2013/8/6 13:37:33)显示成了(2013年8月6日) 第二种方法:model类上面添加DisplayFormat的attribute. 如:
|
1 2 3 4 5 6 7 |
[Display(Name = <span class="string">"</span><span class="string">发布时间:"</span>)] [DisplayFormat(DataFormatString = <span class="string">"</span><span class="string">{0:yyyy年MM月dd日}"</span>)] <span class="keyword">public</span> <span class="keyword">virtual</span> System.DateTime PostTime { <span class="keyword">get</span>; <span class="keyword">set</span>; } |
显示出来后,照样是2013年8月6日这种格式。 from:http://www.cnblogs.com/Rising/p/3722299.html
View Details本文实例讲述了php判断数组中是否存在指定键(key)的方法。分享给大家供大家参考。具体分析如下: php中有两个函数用来判断数组中是否包含指定的键,分别是array_key_exists和isset array_key_exists语法如下 1 array_key_exists($key, $array) 如果键存在返回true isset函数语法如下 1 isset($array[$key]) 如果键存在返回true 演示代码如下: 1 2 3 4 5 6 7 <?php $array = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java"); print("Is 'One' defined? ".array_key_exists("One", $array)."\n"); print("Is '1' defined? ".array_key_exists("1", $array)."\n"); print("Is 'Two' defined? ".isset($array["Two"])."\n"); print("Is '2' defined? ".isset($array[2])."\n"); ?> 返回结果如下: 1 2 3 4 Is 'One' defined? 1 Is '1′ defined? Is 'Two' defined? 1 Is '2′ defined? from:http://www.jb51.net/article/62372.htm
View Detailsphp 5个版本,5.2、5.3、5.4、5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in,看意思就很明了,说mysql_connect这个模块将在未来弃用,请你使用mysqli或者PDO来替代。 解决方法1: 禁止php报错 display_errors = On 改为 display_errors = Off 鉴于这个服务器都是给用户用的,有时候他们需要报错(…都是给朋友用的,^_^),不能这做,让他们改程序吧,看方案2. 解决方法2: 常用的php语法连接mysql如下 <?php $link = mysql_connect('localhost', 'user', 'password'); mysql_select_db('dbname', $link); 改成mysqi <?php $link = mysqli_connect('localhost', 'user', 'password', 'dbname'); 常用mysql建表SQL如下 <?php // 老的 mysql_query('CREATE TEMPORARY TABLE table', $link); // 新的 mysqli_query($link, 'CREATE TEMPORARY TABLE table'); 解决方法三: 在php程序代码里面设置报警级别 <?php error_reporting(E_ALL ^ E_DEPRECATED); Deprecated的问题就这样解决掉了,不过还是建议大家尽快取消mysql的用户,全部都走向mysqli或者mysqlnd等等。mysql确实是太不安全而且太老旧了。 转载请注明出处:http://www.ttlsa.com/html/2502.html
View DetailsASP.NET MVC3中的Model是自验证的,这是通过.NET4的System.ComponentModel.DataAnnotations命名空间完成的。 我们要做的只是给Model类的各属性加上对应的验证标记(Attributes)就可以让MVC3框架帮我们完成验证。我以MVC3项目模板自带的登录 做例子讲解Model的验证。 一、启用客户端验证: 客户端验证主要是为了提高用户体验,在网页不回刷的情况下完成验证。 第一步是要在web.config里启用客户端验证,这在MVC3自带的模板项目中已经有了: <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 然后在被验证的View页面上要加入这样两个JavaScript,注意,他们是依赖于JQuery的: <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> 验证消息的显示有两种,一种是ValidationSummary,它可以显示一份验证消息的汇总,包括从后台Action里返回的消息。 @Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") 另一种是Model中各属性对应HTML控件的验证消息: @Html.ValidationMessageFor(m => m.UserName) 二、在Model中加入验证标记 MVC3项目模板自带的登录模型类如下: public class LogOnModel { [Required] [Display(Name = "User name")] public string UserName { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [Display(Name = "Remember me?")] public bool RememberMe { get; set; } } 对比普通的C#类,我们发现每个属性上都多了被方括号“[]”包围的标记。其中,[Required]是验证标记的一种,而[Display]、[DataType]则是为了显示对应的HTML控件,这不在本文讨论范围之内。 除了Required,我们还可以在Model中添加其他有用的验证标记。下面是个较完整的列表: Model类中可以添加的验证标记: 1. 必填字段 [Required] public string FirstName { […]
View Details近日,需要满足测试需求,进行大数据并发测试时,报出【HTTP 错误 500.0 – Internal Server Error E:\PHP\php-cgi.exe – FastCGI 进程超过了配置的活动超时时限】 解决办法: IIS7->FastCGI设置->双击"php-cgi.exe"->"活动超时" 项默认是设置为70(秒),改为600(10分钟,此处根据需求设置可以略高~) from:http://blog.csdn.net/abandonship/article/details/8730524
View Details安装好MySQL服务后(安装步骤可以参考系列经验1)。打开“系统偏好设置”,单击下端的“MySQL”图标。 在“MySQL”对话框中,单击“启动MySQL服务”按钮。 在弹出的窗口中,输入管理员密码,然后单击“好”按钮。 在“MySQL”对话框中,MySQL服务的状态显示为:如下状态表示MySQL服务已经启动。 使用终端登录MySQL: 在Finder的侧边栏中单击“应用程序”,然后在“实用工具”中,双击启动“终端”命令。 在终端中输入添加MySQL路径的命令: PATH="$PATH":/usr/local/mysql/bin 在终端登录到MySQL的命令如下:mysql -u root -p 然后输入密码,如果没有设置密码,直接按enter键。 如果显示的内容如下,即是已经成功登录到MySQL服务。
View Details1.启动 sudo apachectl -k start 2.重新启动 sudo apachectl -k restart //——————————————————————— 设置Apache容器默认目录(不会命令行的朋友可以参考下面的常用命令) 1.Apache配置文件所在目录 cd /etc/apache2/ 2.修改Apache配置文件 sudo vim httpd.conf 3.查找 DocumentRoot 字符串。“/”为查找定位的意思 /DocumentRoot 4. 将上述查找到的木木修改为自己想要的目录即可。 5.重新启动Apache。 //———————————————————————-- 常用命令:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
vim中有两种模式 命令模式,用于输入命令(注意输入法要在英文状态) shift+V 可以选中一行 y 复制一行 p 在当前行下方粘贴复制的内容 d$ 删除到行尾 x 删除一个字符 :wq 保存退出 :q! 不保存退出 i 进入编辑模式 编辑模式:用于编辑按ESC可以切换回命令模式 |
//—————————————————————- 若要支持PHP,执行如下: 1. cd /etc/apache2 sudo vim httpd.conf /php #LoadModule php5_module … 2.按字母x,删除#,然后按ESC,输入:wq退出编辑器 cd /etc/ 3.复制一份php.ini sudo cp php.ini.default php.ini 4.重新启动Apache服务器 命令回顾说明:
|
1 2 3 4 5 |
cd /etc/apache2/ 进入apache的配置文件目录 sudo cp file1 file2 将file1复制到file2 sudo vim httpd.conf 使用vim打开httpd.conf文件 sudo apachectl -k start 启动apache sudo apachectl -k restart 重新启动apache |
from:http://www.cnblogs.com/surge/p/4168220.html
View Details系统: OS X Yosemite 10.10.1 系统自带php和php-fpm 路径备注:
|
1 2 3 4 |
php.ini: /etc/ php-fpm.conf:/etc/ nginx.conf:/usr/local/etc/nginx/nginx.conf nginx 默认root:/usr/local/opt/nginx/html |
1.安装nginx,我使用了brew
|
1 |
brew install nginx |
2.启动php-fpm
|
1 |
sudo php-fpm |
如果报错的话,复制php-fpm.conf.default一份,修改php-fpm.conf的error_log 存放的路径或启动的端口 3.打开nginx.conf 开启php的注释,配置好自己的root
|
1 2 3 4 5 6 7 |
location ~ \.php$ { root /Users/maming/php; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |
注意
|
1 2 3 4 5 |
SCRIPT_FILENAME /script$fastcgi_script_name; 要改成 SCRIPT_FILENAME $document_root$fastcgi_script_name; |
否则回报文件不存在的。 4.开启nginx
|
1 2 3 4 |
sudo nginx 或重启 sudo nginx -s reload |
from:http://www.2cto.com/os/201504/390021.html
View Details