• PHP 要点记录


    instanceof Class类型判断。 $cat1 = new Cat; if($cat1 instanceof Cat){...}

    break 2; 跳出2重循环 -- 同理continue 2

    每个函数开辟新的栈。变量均是相互独立的。

    "" 双引符号中 $a 变量会被正常解析, '' 单引不会

    函数地址传递 & 就是C++中的引用

    类静态属性, 内部访问self:: CLASS:: 类外部CLASS::

    extends . 子类创建时候不会自动调用父类构造方法

    interface implements 接口中可以有属性,但必须是常量

    final关键字final class A{}禁止继承类 final function Fun1(){}禁止override方法

    const常量 类或接口外部调用方式 类::const 接口::const const前面不带public private修饰符

    php错误日志保存:error_log(errorInfo."r\n", 3, "error.txt");

    在php.ini中找到并修改时区: date.timezone = Asia/Chongqing

    try throw catch(Exception $e) $e->getMessage(); $e->getLine();

    print_r($_SERVER);

    mysqli->multi_query(); 批量执行SQL语句

    事务保持数据一致性:mysqli->autocommit(false); mysqli->rollback(); mysqli->commit();

    global_register默认而且应该关闭off

    设置cookie setcookie($key, $value, time()+3600*24) //保存一天
    删除cookie setcookie($key, '', time()-1)
    获取cookie $_COOKIE[$key]
    session_start();
    $_SESSION[$key]=$name; //session保存路径 在php.ini中设置
    session_destory();
    客户端禁用cookie,仍然使用SESSION 得传递session_id(SESSION是如何借助COOKIE工作的) SID
    parse_ini_file("*.ini")
    上传文件 <from action='' method='' enctype='multipart/form-data'></form>
    PHP正则preg_matcg preg_match_all的 匹配建议使用 '' 不使用""
    ENGINE = MYISAM
    truncate table比DELETE更快删除表数据

    smarty:
    修改分隔符{}方法 修改源码$left_delimiter 或者 $smarty=new Smarty();$smarty->left_delimiter='<{';
    配置{config_load file='路径'} 使用{#KEY#}
    .tpl模板 获取$_GET $_POST $_SERVER....数据 可以在tpl模板直接 使用$smarty.get. $smarty.server.
    foreach from item key
    if elseif else /if
    自定义函数:register_function(); 块注册函数方式:register_block();
    smarty 变量操作符,变量调节器
    {foreach} {foreachelse} {/foreach} 当foreach变量不存在时候,执行foreachelse下面的代码
    {include file=''} 模板之间包含
    {literal}{/literal} 包含的内容,不被SMARTY引擎解析。当作存文本输出
    $smarty->debugging=
    $smarty->cache_dir='' $smarty->caching=true $smarty->lifetime=60 秒
    局部缓存:{blockname}{/blockname} insert_xxx 函数
    当模板有多个缓存时,可以带上第二个参数:is_cached('article.html',$art_id) $tpl->clear_cache('article.html',$art_id); //清除同一个模板下的指定缓存号的缓存

    ZendFrameWork
    1.zf.bat create project d:\wwww\zfpro
    2.引入ZF的lib下面的zend库进ZEND STUDIO
    3.php.ini启用PDO
    4.APACHE中开启mod_rewrite , 并设置所有AllowOverride=All
    5.新配置APACHE虚拟主机,将DocumentRoot 配置到....../public 目录
    6.php.ini中error_log帮助调试

    apache的并发访问测试:
    ab.exe -n 10000 -c 10 http://localhost/test.php
    -n 并发访问次数
    -c 同时多少人访问

  • 相关阅读:
    洛谷P2516 [HAOI2010]最长公共子序列 动态规划 容斥原理
    [LeetCode]235. Lowest Common Ancestor of a Binary Search Tree
    [LeetCode]144. Binary Tree Preorder Traversal二叉树前序遍历
    [LeetCode]129. Sum Root to Leaf Numbers路径数字求和
    [leetcode]645. Set Mismatch
    [leetcode]110BalancedBinaryTree平衡二叉树
    [leetcode]199. Binary Tree Right Side View
    [LeetCode]116. Populating Next Right Pointers in Each Node
    [leetcode]720. Longest Word in Dictionary字典中最长的单词
    [LeetCode]690. Employee Importance员工重要信息
  • 原文地址:https://www.cnblogs.com/qunshu/p/3128026.html
Copyright © 2020-2023  润新知