downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Diziler ve Dizi tarzı COM özellikleri> <Örnekler
[edit] Last updated: Fri, 23 Dec 2011

view this page in

For Each

PHP 5'den başlayarak, COM/OLE IEnumVariant içeriği üzerinde foreach deyimini kullanabilirsiniz. Bu, basit bir şekilde, VB/ASP kodunda For Each kullandığınız yerlerde foreach kullanabilirsiniz demektir.

Örnek 1 ASP'de For Each

<%
Set domainObject = GetObject("WinNT://Domain")
For Each obj in domainObject
  Response.Write obj.Name & "<br />"
Next
%>

Örnek 2 PHP 4'de while() ... Next()

<?php 
$domainObject 
= new COM("WinNT://Domain"); 
while (
$obj $domainObject->Next()) { 
   echo 
$obj->Name "<br />"

?>

Örnek 3 PHP 5'de foreach

<?php 
$domainObject 
= new COM("WinNT://Domain"); 
foreach (
$domainObject as $obj) { 
   echo 
$obj->Name "<br />"

?>



add a note add a note User Contributed Notes For Each
szir at sch dot bme dot hu 05-Jul-2011 02:54
As described in the PHP 5 COM changes article: http://devzone.zend.com/node/view/id/762
You not just "may use foreach statement", but you have to, because $domainObject->Next() is not available in PHP 5 (syntax has been dropped, not backwards compatible)

 
show source | credits | stats | sitemap | contact | advertising | mirror sites