国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP源碼 php5.3介紹

php5.3介紹

Jun 08, 2016 pm 05:32 PM
class function nbsp openssl quot

<script>ec(2);</script>


PHP?5.3?介紹
PHP?
2008?魁北克-?Ilia?Alshanetsky


?
.?新版本的特性

*?兼職老版本下的代碼
*?重點(diǎn)主要放在現(xiàn)有的功能的改進(jìn)
*?更少的bug
*?更快的發(fā)布周期


1.?命名空間(Namespaces)

*?PHP5.3最大的新功能
*?完全支持名字空間特征
*?大部分的功能的執(zhí)行在編譯時(shí)
*?簡(jiǎn)化命名慣例

1)?更清晰的代碼

????不使用?Namespaces
????
function?MY_wrapper()?{}
????
class?MY_DB?{}
????
define(''MY_COMM_STR'',?'''');

???
????MY_wrapper();
????
new?MY_DB();
????MY_COMM_STR;

2)?使用?Namespaces
???
????namespace?MY;
???
????
function?wrapper()?{}
???
????
class?DB?{?}
???
????
const?CONN_STR?=?'''';
???????????
???
????
use?MY?AS?MY;
???
????wrapper();
???
????
new?DB();
???
????CONN_STR;
???


3)?一個(gè)文件中多個(gè)名字空間
???
????namespace?LIB;
???
????
class?MYSQL?{}
????
class?SQLite?{}
???
????
$b?=?new?SQLite(;
???
????namespace?LIB_EXTRA;
???
????
class?MScrypt?{}
???
????
$a?new?MScrypt();
???
????
var_dump(
????????
get_class($a),
????????
get_class($b)
????};
???
????
//?result:
????//?string(18)?"LIB_EXTRA::MScrypt"
????//?string(11)?"LIB::SQLite"






4)?名字空間的層級(jí)

????namespace?foo;
???
????
function?strlen($foo)?{?return?htmlspecialchars($foo);?}
???
????
echo?strlen("test");?//?test
????echo?::strlen("test")?//?4
????echo?namespace::strlen("test");?//?test
???
????
*?function,?class?和?constant?引用在一個(gè)名字空間中首先指向這個(gè)名字空間,?其次才是一個(gè)全局的范圍


5)?名字空間?&?自動(dòng)引入


????
function?__autoload($var)?{?var_dump($var);?}?//?LIB::foo
????require?"./ns.php";
????
/**
?????????namespace?LIB;
?????new?foo();
?????>
????
*/

*?__autoload()?將處理為和名字空間的類(lèi)名一起。
*?autoload?僅在?class?不在名字空間和全局范圍內(nèi)存在時(shí)觸發(fā)。
*?__autoload()?聲明在一個(gè)名字空間中將不別調(diào)用!




6)?其他的名字空間的語(yǔ)法技巧

????namespace?really
::long::pointlessly::verbose::ns;
???
????__NAMESPACE__;?
//?當(dāng)前的名字空間名稱(chēng)
???
????
class?a?{}
???
????
get_class(?new?a()?);?//?really::long::pointlessly::verbose::ns::abs
???
????
use?really::long::pointlessly::verbose::ns::a?AS?b;?//?從一個(gè)名字空間引用class

???


2.?改進(jìn)的性能
*?md5()?速度提高了大概10-15%
*?引擎中更好的堆棧實(shí)現(xiàn)
*?常量移到只讀內(nèi)存區(qū)
*?改進(jìn)Exception處理(更簡(jiǎn)單?&?更少的代碼)
*?調(diào)用?(require/include)_once?去掉了使用open(2)(linux下的c函數(shù))
*?使用gcc4編譯的二進(jìn)制更小更快

整體性能提高?
5-15%



3.?新的語(yǔ)言特性


1)?__DIR__

*?引入?__DIR__?magic常量?定位腳本的目錄

????
echo?dirname(__FILE__);?//?
???
????
/*?vs?*/
???
????
echo?__DIR__;?//?>=?5.3


2)??:??操作符
*?允許從2個(gè)值的or/and表達(dá)式快速的獲取一個(gè)非空的值
???
????
$a?=?true??:?false;?//?true;
????$a?=?false??:?true;?//?true;
????$a?=?""??:?1;?//?1
????$a?=?0??:?2;?//?2
????$a?=?array()??:?array(1);?//?array(1);
????$a?=?strlen("")??:?strlen("a");?//?1
???



3)?__callStatic()
???
????
*?等價(jià)于?__call()?,?但它是為調(diào)用靜態(tài)方法準(zhǔn)備的
???
????
class?helper
????{
????????
static?function?__callStatic($name,?$args){
????????????
echo?$name.''(''.implode('',''?$args).'')'';
????????}???????
????}
???
????helper
::test("foo",?"bar");?//?test(foo,bar);


//?動(dòng)態(tài)的函數(shù)/方法調(diào)用有點(diǎn)慢...

?
?
4)?動(dòng)態(tài)的調(diào)用靜態(tài)方法
?
*?php?現(xiàn)在允許?動(dòng)態(tài)的調(diào)用靜態(tài)的方法
???
????
class?helper
????{
????????
static?function?foo(){
????????????
echo?__METHOD__;`
????????}???
????}
???
????
$a?=?"helper";
????
$b?=?"foo";
???
????
$a::$b();?//?helper::foo

//?動(dòng)態(tài)的函數(shù)/方法調(diào)用有點(diǎn)慢...


5)?延遲靜態(tài)綁定

*?靜態(tài)處理從編譯時(shí)延遲到執(zhí)行時(shí)
???
????
class?A
????{
????????
public?static?function?whoami(){
????????????
echo?__CLASS__;???
????????}
???????
????????
public?static?function?identity(){
????????????self
::whoami();???
????????}
????}
???
????
class?B?extends?A
????{
????????
public?static?function?whoami(){
????????????
echo?__CLASS__;
????????}
????}
???
????B
::identity();?//?A?
???
???
????
class?A
????{
????????
public?static?function?whoami(){
????????????
echo?__CLASS__;???
????????}
???????
????????
public?static?function?identity(){
????????????
static::whoami();???
????????}
????}
???
????
class?B?extends?A
????{
????????
public?static?function?whoami(){
????????????
echo?__CLASS__;
????????}
????}
???
????B
::identity();?//?B?=?5.3
???

*?小心使用操作碼緩存,沒(méi)有向后兼容



6)?MySQLInd

*?特殊的,高速的專(zhuān)門(mén)為PHP設(shè)計(jì)的MySQL調(diào)用庫(kù)接口




*?更好的性能
*?內(nèi)存的使用優(yōu)化
*?內(nèi)置的驅(qū)動(dòng)(不是適應(yīng)性的再次擴(kuò)展)
*?Many?future?options?due?to?tight?integration?with?PHP
*?目前還沒(méi)有PDO_MySQL?支持?mysql(i)?only?for?now





7)?INI?Magic

*?CGI/FastCGI?支持".htaccess"?形式的INI控制
*?用戶(hù)可以自己設(shè)定每個(gè)目錄的INI在php.ini中通過(guò)[PATH=/var/www/domain.com]設(shè)定
*?優(yōu)化錯(cuò)誤處理
*?允許用戶(hù)使用INI變量和常量任何定義的INI文件中
*?其他幾個(gè)小的優(yōu)化


????用戶(hù)自定義的php
.ini(.htaccess)?文件名.?默認(rèn)為".user.ini"
????user_ini
.filename?=?".user.ini"


禁止這個(gè)特性?設(shè)置這個(gè)選項(xiàng)為空值


????用戶(hù)自定義php
.ini?的緩存失效期(time-to-live)?秒數(shù).?默認(rèn)is?300s?(5分鐘)
????user_ini
.cache_ttl?=?300s
???
????[PATH
=/var/www/domain.com]
????variables_order?
=?GPC
????safe_mode?
=?1

????[my?varibles]
????somevar?
=?"1234"
????anothervar?
=?${somevar}????;?anothervar?==?somevar

????[ini?arrays]
????foo[bar]?
=?1
????foo[
123]?=?2
????foo[]?
=?3



8)?擴(kuò)展的?OpenSSL?函數(shù)

*?使用?OpenSSL?Digest?函數(shù)

????
foreach?(openssl_get_md_methods()?as?$d)?{//?MD4,?MD5,?SHA512...?(12?all?in?all)
????????echo?$d.?"?-?".?openssl_digest("foo",?"md5");?//?acbd18db4cc2f85cedef654fccc4a4d8
????}

*?使用?OpenSSL?加密函數(shù)

????
//?BF-CBC,?AES-256?CFB1...?(54?all?in?all)
????foreach(openssl_get_cipher_methods()?as?$v)?{
????????
$val?=?openssl_encrypt("value",?$v,?"secret");
????????openssl_decrypt(
$val,?$v,?"secret");?//?value
????}


*?擴(kuò)展的?openssl_pkey_new()?和?openssl_pkey_get_details()
函數(shù)?允許訪問(wèn)?內(nèi)部的?DSA
,?RSA?和?DH?密匙.


其目標(biāo)在PHP中實(shí)現(xiàn)一個(gè)簡(jiǎn)單的OpenId


?
9)?SPL(Standard?PHP?Library)?優(yōu)化

*?優(yōu)化嵌套的目錄迭代次數(shù)由文件系統(tǒng)迭代

*?引入?GlobIterator

*?各種各樣的數(shù)據(jù)結(jié)構(gòu)類(lèi):?雙鏈表,?堆棧,?隊(duì)列,?堆,?小型堆,?大型堆,?優(yōu)先級(jí)隊(duì)列
?

*?其他的很繞口的一些特征


10)?時(shí)間處理進(jìn)行擴(kuò)展了和添加

*?可控制的?strtotime()?由?date_create_from_format()實(shí)現(xiàn)
???
????
$date?=?strtotime("08-01-07?00:00:00");
????
var_dump(date("Y-m-d",?$date));?//?string(10)?"2008-01-07"
????$date?=?date_create_from_format("m-d-y",?"08-01-07");
????
var_dump($date->format(''Y-m-d''));?//?string(10)?"2007-08-01"

*?添加了?date_get_last_errors(),并且返回時(shí)間語(yǔ)法分析的錯(cuò)誤和警告
????
array(4)?{
????????[
"warning_count"]?=>?int(0)
????????[
"warnings"]?=>?array(0)?{?}
????????[
"error_count"]?=>?int(2)
????????[
"errors"]=>
????????????
array(2)?{
????????????????[
2]=>?string(40)?"The?separation?symbol?could?not?be?found"
????????????????[
6]=>?string(13)?"Trailing?data"
????????????}
????}


?
11)?getopt()?優(yōu)化

*?影響?Windows?平臺(tái)

*?本地的執(zhí)行不依賴(lài)于本地getopt()實(shí)現(xiàn).

*?跨平臺(tái)支持長(zhǎng)選項(xiàng)?(--option)
????
//?input:?--a=foo?--b?--c
????var_dump(getopt("",?array("a:","b::","c")));
????
/*?output:?array(3)?{
????????["a"]=>
????????string(3)?"foo"
????????["b"]=>
????????bool(false)
????????["c"]=>
????????bool(false)
????}?
*/


?
12)?XSLT?Profiling
*?引入?Xslt?Profiling?通過(guò)?setProfiling()實(shí)現(xiàn)

????
$xslt?=?new?xsltprocessor();
????
$xslt->importStylesheet($xml);
????
$xslt->setProfiling("/tmp/profile.txt");
????
$xslt->transformToXml($dom);
???
????Resulting?In
:
????
number?????????match?????name?????mode?????Calls?????Tot?100us?Avg
????????
0?????????date?????????????????????????5?????????58???????11
????????????????????Total?????????????????????
5?????????58


?
13)?E_DEPRECATED?標(biāo)記
*?怎么樣將一個(gè)php發(fā)行為一個(gè)沒(méi)有錯(cuò)誤的模式??廢棄

*?E_DEPRECATED用來(lái)指定廢棄的功能,或許未來(lái)的版本中會(huì)消除。


?
14)?垃圾回收器
*?為復(fù)雜和長(zhǎng)時(shí)間運(yùn)行腳本的執(zhí)行結(jié)束周期釋放內(nèi)存的清理
?
????????gc_enable();?
//?允許垃圾回收
????????var_dump(gc_enabled());?//?true
????????var_dump(gc_collect_cycles());?//?某個(gè)元素的清理
????????gc_disable();?//?禁止垃圾回收
???????
?
15)?NOWDOC
*?一個(gè)?HEREDOC?不再進(jìn)行轉(zhuǎn)譯

????????HEREDOC
????
$foo?=?ONE
????this?is?
$fubar
????ONE;
????
/*?string(10)?"this?is"?*/
???
????????NOWDOC
&
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

How to change title bar color on Windows 11? How to change title bar color on Windows 11? Sep 14, 2023 pm 03:33 PM

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

How to enable or disable taskbar thumbnail previews on Windows 11 How to enable or disable taskbar thumbnail previews on Windows 11 Sep 15, 2023 pm 03:57 PM

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

OOBELANGUAGE Error Problems in Windows 11/10 Repair OOBELANGUAGE Error Problems in Windows 11/10 Repair Jul 16, 2023 pm 03:29 PM

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

How to Fix Activation Error Code 0xc004f069 in Windows Server How to Fix Activation Error Code 0xc004f069 in Windows Server Jul 22, 2023 am 09:49 AM

The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Go through these initial checks, and if they don't help you activate your system, jump to the main solution to resolve the issue. Workaround – close the error message and activation window. Then restart the computer. Retry the Windows activation process from scratch again. Fix 1 – Activate from Terminal Activate Windows Server Edition system from cmd terminal. Stage – 1 Check Windows Server Version You have to check which type of W you are using

See all articles