1--TEST-- 2Test function getservbyname() by substituting argument 1 with object values. 3--FILE-- 4<?php 5 6 7echo "*** Test substituting argument 1 with object values ***\n"; 8 9$protocol = "tcp"; 10 11 12class classWithToString 13{ 14 public function __toString() { 15 return "Class A object"; 16 } 17} 18 19class classWithoutToString 20{ 21} 22 23$variation_array = array( 24 'instance of classWithToString' => new classWithToString(), 25 'instance of classWithoutToString' => new classWithoutToString(), 26 ); 27 28 29foreach ( $variation_array as $var ) { 30 var_dump(getservbyname( $var , $protocol ) ); 31} 32?> 33--EXPECTF-- 34*** Test substituting argument 1 with object values *** 35bool(false) 36 37Warning: getservbyname() expects parameter 1 to be string, object given in %s.php on line %d 38NULL 39