1--TEST-- 2Test realpath() function: usage variation 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die('skip only on Windows'); 7} 8?> 9--FILE-- 10<?php 11require __DIR__.'/file.inc'; 12 13echo "*** Testing realpath(): usage variations ***\n"; 14$name_prefix = __DIR__; 15$filename = "$name_prefix/realpath_variation_私はガラスを食べられます/home/tests/realpath_variation_私はガラスを食べられます.tmp"; 16mkdir("$name_prefix/realpath_variation_私はガラスを食べられます/home/tests/", 0777, true); 17 18echo "\n*** Testing realpath() with filename stored inside a object ***\n"; 19// create a temp file 20$file_handle = fopen($filename, "w"); 21fclose($file_handle); 22 23// creating object with members as filename 24class object_temp { 25 public $filename; 26 function __construct($file) { 27 $this->filename = $file; 28 } 29} 30$obj1 = new object_temp("$name_prefix/realpath_variation_私はガラスを食べられます/../././realpath_variation_私はガラスを食べられます/home/tests/realpath_variation_私はガラスを食べられます.tmp"); 31$obj2 = new object_temp("$name_prefix/realpath_variation_私はガラスを食べられます/home/..///realpath_variation_私はガラスを食べられます.tmp"); 32 33var_dump( realpath($obj1->filename) ); 34var_dump( realpath($obj2->filename) ); 35 36echo "\n*** Testing realpath() with filename stored in an array ***\n"; 37$file_arr = array ( 38 "$name_prefix////realpath_variation_私はガラスを食べられます/home/tests/realpath_variation_私はガラスを食べられます.tmp", 39 "$name_prefix/./realpath_variation_私はガラスを食べられます/home/../home//tests//..//..//..//home//realpath_variation_私はガラスを食べられます.tmp/" 40); 41 42var_dump( realpath($file_arr[0]) ); 43var_dump( realpath($file_arr[1]) ); 44 45echo "\n*** Testing realpath() with filename as empty string, NULL and single space ***\n"; 46$file_string = array ( 47 /* filename as spaces */ 48 " ", 49 ' ', 50 51 /* empty filename */ 52 "", 53 '', 54 ); 55for($loop_counter = 0; $loop_counter < count($file_string); $loop_counter++) { 56 echo "-- Iteration"; 57 echo $loop_counter + 1; 58 echo " --\n"; 59 var_dump( realpath($file_string[$loop_counter]) ); 60} 61 62echo "Done\n"; 63?> 64--CLEAN-- 65<?php 66$name_prefix = __DIR__."/realpath_variation_私はガラスを食べられます"; 67unlink("$name_prefix/home/tests/realpath_variation_私はガラスを食べられます.tmp"); 68rmdir("$name_prefix/home/tests/"); 69rmdir("$name_prefix/home/"); 70rmdir("$name_prefix/"); 71?> 72--EXPECTF-- 73*** Testing realpath(): usage variations *** 74 75*** Testing realpath() with filename stored inside a object *** 76string(%d) "%s\realpath_variation_私はガラスを食べられます\home\tests\realpath_variation_私はガラスを食べられます.tmp" 77bool(false) 78 79*** Testing realpath() with filename stored in an array *** 80string(%d) "%s\realpath_variation_私はガラスを食べられます\home\tests\realpath_variation_私はガラスを食べられます.tmp" 81bool(false) 82 83*** Testing realpath() with filename as empty string, NULL and single space *** 84-- Iteration1 -- 85bool(false) 86-- Iteration2 -- 87bool(false) 88-- Iteration3 -- 89string(%d) "%s" 90-- Iteration4 -- 91string(%d) "%s" 92Done 93