?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
void append_by_ref
(string
varname, mixed var)
void append_by_ref
(string
varname, mixed var, boolean merge)
This is used to append values to the templates by reference. If you
append a variable by reference then change its value, the appended
value sees the change as well. For objects, append_by_ref() also avoids
an in-memory copy of the appended object. See the PHP manual on
variable referencing for an in-depth explanation. If you pass the
optional third parameter of true, the value will be merged with the
current array instead of appended.
本函數(shù)用于采用引用的方式把變量的值添加到原有值之后。如果采用引用的方式添加了一個變量,那么當這個變量的值改變時,被添加的值也隨之改變。對于
對象,append_by_ref()函數(shù)也能夠避免對于被添加對象的內存拷貝。關于變量引用的進一步解釋可以查看PHP手冊。如果第三個可選參數(shù)設置為
true,數(shù)值將會和現(xiàn)有數(shù)組合并,而不是添加在數(shù)組后面。
Technical Note: The merge parameter respects array keys, so if you merge two numerically indexed arrays, they may overwrite each other or result in non-sequential keys. This is unlike the array_merge() function of PHP which wipes out numerical keys and renumbers them.
注意:使用第三個參數(shù)“merge”時要考慮到數(shù)組的索 引,所以,如果添加和被添加的數(shù)組都是以數(shù)字為索引,他們會互相覆蓋,或者產生不連續(xù)的索引。這并不象PHP中的array_merge()函數(shù),后者會 刪除原有的數(shù)字索引,重新對索引進行編號。
Example 13-2. append_by_ref
|