乐知者-知之者不如好之者, 好之者不如乐之者
关于PHP cURL:SSL certificate error: unable to get local issuer certificate 问题
Window下PHP调用curl接口访问https网址时报错: SSL certificate error: unable to get local issuer certificate 尝试关闭SSL_VERIFY验证，也可以解决问题，但是强烈不建议用该方法： curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0); 最好的解决办法是添加certificate认证文件并修改PHP.ini配置认证文件下载地址：https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt| d377ff1a34799bafe2ede779d472736111 |php.ini 修改如下： curl.cainfo="C:/wamp/ca-bundle.crt" openssl.cafile="C:/wamp/ca-bundle.crt" 问题彻底解决
问题描述这两天网站页面中城市名称显示的地方不正常，但是有些地方也正常。调用城市代码用了Memcache缓存，扩展是Memcache。 经过调试后发现调用城市数据的时候有些城市数据返回的是：string(398) "a:18:{s:2:"id";i:4;s:4:"name";s:6:"重庆";s:5:"alias";s:9:"chongqing";s:4:"bjdx";s:2:"cq";s:4:"type";i:1;s:8:"parentid";i:0;s:8:"haschild";i:1;s:4:"path";s:1:"4";s:6:"domain";s:9:"chongqing";s:5:"quhao";s:3:"023";s:6:"chepai";s:29:"渝A,渝B,渝C,渝F,渝G,渝H";s:5:"color";s:6:"0000FF";s:5:"cs_id";i:35;s:5:"level";i:4;s:5:"class";i:1;s:10:"bdcitycode";i:132;s:6:"status";i:1;s:7:"version";i:1;}" string(398) "a:18:{s:2:"id";i:4;s:4:"name";s:6:"重庆";s:5:"alias";s:9:"chongqing";s:4:"bjdx";s:2:"cq";s:4:"type";i:1;s:8:"parentid";i:0;s:8:"haschild";i:1;s:4:"path";s:1:"4";s:6:"domain";s:9:"chongqing";s:5:"quhao";s:3:"023";s:6:"chepai";s:29:"渝A,渝B,渝C,渝F,渝G,渝H";s:5:"color";s:6:"0000FF";s:5:"cs_id";i:35;s:5:"level";i:4;s:5:"class";i:1;s:10:"bdcitycode";i:132;s:6:"status";i:1;s:7:"version";i:1;}"这个问题是memcache->get返回的数据没有经过unserialize处理，就直接返回了，所以导致页面中$array['key']调用的时候显示异常。目前仍旧无法分析出来具体原因, 先记录下来以后再分析。目前可以确定如下情况： 最近没有升级过服务器和相关服务； 缓存设置的地方是正常的； 只有部分城市出现过问题； 重启过memcached服务, 并不解决问题； PHP版本5.4.45
数据类型1、直接声明变量或者常量，数据类型隐世定义let MyConst = 10 var MyVarible = 12 MyVarible = 302、显式声明变量的数据类型let implicitInteger = 70 let implicitDouble = 40.0 let explicitDouble: Double = 70.03、数据类型转换需要显示声明let label = "This width is " let width = 45 let widthlabel = label + String(width) var implicitDouble1 = implicitInteger + Int(implicitDouble)4、一个简单的技巧在字符串中包含变量, 将变量放置在小括号中"()"， 同时在小括号前加反斜线"\"let apples = 3 let oranges = 5 let appleSummary = "I have (apples) apples" let fruitSummary = "I have (apples + oranges) piecies of fruite."5、创建数组和字典用方括号"[]", 通过在方括号中放索引或者键值来访问它们的子元素。最后一个元素后边可以放置逗号*/var ShoppingList = ["catfish", "water", "tulips", "bluepaint",] ShoppingList[1] = "bottle of water" var str1: String = ShoppingList[1]print(ShoppingList)var occupations = ["Malcolm":"Captain", "Kaylee":"Mechanic"] print(occupations)var arrayTest = [1, 2, 3, 4, "5"]//数据类型为NSObject //var int1: Int = arrayTest[0]//wrong //var str1:String = arrayTest[1]//wrong6、可以用如下方式初始化一个空数组或者空字典var emptyArray1 = String var emptyDictionary2 = String: Float //当类型可以推断出的时候可以用如下方式初始化, 例如为变量设置新值或者为函数传递参数的时候 var emptyArray2 = [] var emptyDictory2 = [:]流程控制let individualScores = [71, 32, 43, 74, 55] var teamScore = 0; for score in individualScores { if(score > 50) {//if条件必须是Boolean值, 如果不和0显式的比较而使用if(score)是错误的 teamScore += 3; } else { teamScore += 1; } } print(teamScore)You can use if and let together to work with values that might missing. These values are represented as optionals. An optional value either contains a value or contains nil to indicate that a value is missing. Write a question make(?) after that type of value to mark the value as optional.var optionString: String? = "hello" print(optionString == nil) var optionalName: String? = "John Appleseed"//if set nil and "if" condition is false var greeting = "Hello!" if let name = optionalName {//const name only available inside the block greeting = "hello, (name)" } else { greeting = "Oh" } //Optional values has questiong //let nickName: String? = nil let nickName: String? = "Smith" let fullName: String = "John Appleseed" let infomalGreeting = "Hi (nickName ?? fullName)"9、Switches support any kind of data and a wide variety of comparision operations-they aren't limited to integers and tests for equalitylet vegetable = "red pepper" switch vegetable { case "celery"://case 不需要使用break退出 print("Add some raisins and make ants on a log.") case "cucumber", "watercress"://多个选项用逗号隔开 print("That would make a good tea sandwich.") case let x where x.hasSuffix("pepper"): print("Is it a spicy (x)") default://default 选项不能省去 print("Everything tastes good in soup.") }Notice how let can be used in a pattern to assign the value that matched the pattern to a constant.10、词典是无序的let interestingNumbers = [ "Prime": [2, 3, 5, 7, 11, 13], "Fibonacci": [1, 1, 2, 3, 5, 8], "Square": [1, 4, 9, 16, 25] ] var largest = 0; var witchkind = ""; for (kind, numbers) in interestingNumbers { for number in numbers { if number > largest { witchkind = kind; largest = number } } } print("The largest number in (witchkind) is (largest)")11、While循环var n = 2; while n < 100 { n = n * 2 } print(n) var m = 128 repeat { m *= 2 } while m < 100 print(m)12、Use ..< make a range that omits its upper value, and use ... to make a range that includes both values.var total = 0 for i in 0..<4 { total += i } print(total) total = 0 for i in 0...4 { total += i } print(total)
在开发程序过程中经常需要终端下查找某个文件夹或者文件下包含某关键字的文件列表， 下面的命令会有帮助find ./ -name "*.php"|xargs grep "keywords"如果要显示行号需要加在grep里加n参数find ./ -name "*.php"|xargs grep -n "keywords"