我所不知道的php

 

life is like a box of chocolates. you never know what you re gonna get
人生确实是不可预知的,在刚刚号称熟悉C#之后,一次我都没抱希望的面试机会竟然把自己送到了Bidu。当看着job description的时候,我就知道一切都要重新来过了,因为jd里面7项要求中的6项,我都是一无所知,唯有最宽泛的一项--有测试领域相关经验,还能沾点边。
好了,新手入门,先从摘抄一些php的资料开始吧。由于实在不知道怎么学,于是基本在读 www.php.net上的东西,路过的兄弟姐妹们有经验的还请指条明路。纯新人,毫无系统性可言,先粗略的记点自己感到惊奇的东西:
 
(先从一个雷人的开始)
 
结果揭晓:前四个全是true, 最后一个false...
 
(function)Any valid PHP code may appear inside a function, even other functions and class definitions.
 
(浮点数)So never trust floating number results to the last digit, and never compare floating point numbers for equality. If higher precision is necessary, the arbitrary precision math functions and gmp functions are available.
 
(类型转化)If an object is converted to an object, it is not modified. If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created. If the value was NULL, the new instance will be empty. Arrays convert to an object with properties named by keys, and corresponding values. For any other value, a member variable named scalar will contain the value.
 
(资源类型,竟然有gc的)Thanks to the reference-counting system introduced with PHP 4's Zend Engine, a resource with no more references to it is detected automatically, and it is freed by the garbage collector. For this reason, it is rarely necessary to free the memory manually. You can use persistence connection functions to avoid gc, such as mysql_pconnect().
 
(类型转化)
 
(HEREDOC & NOWDOC 看来本质上就是single quoted和double quoted的区别,不过指定方法很奇怪)Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc.
 
(Array 至强大的数据结构,很多时候把它当C#的Dictionary<>在用)An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible.
 
php中index的真实意义:
  灵活度可见一斑:
php版的IList<>.Add()么...
 
(local / global /superglobal scope/static)local不用多说,global在函数中用到时,需要显式声明,supperglobal可以直接用,如$_POST, $_SESSION, $GLOBALS etc. 另外,php的static variable像C语言中一样,可以定义在函数内部。
<?php
$a = 1; /* global scope */
function test()
{
    echo $a; /* reference to local scope variable */
}
test(); /* This script will not produce any output because the echo statement refers to a local version of the $a variable, and it has not been assigned a value within this scope. */
?>
There are 2 correct way to meet our needs:
OR
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值