1--TEST-- 2mysqli_real_escape_string() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--FILE-- 9<?php 10 require_once("connect.inc"); 11 12 require('table.inc'); 13 14 if ('фу\\\\бар' !== ($tmp = mysqli_real_escape_string($link, 'фу\\бар'))) 15 printf("[004] Expecting фу\\\\бар, got %s\n", $tmp); 16 17 if ('бар\"фус' !== ($tmp = mysqli_real_escape_string($link, 'бар"фус'))) 18 printf("[005] Expecting бар\"фус, got %s\n", $tmp); 19 20 if ("лала\'лали" !== ($tmp = mysqli_real_escape_string($link, "лала'лали"))) 21 printf("[006] Expecting лала'лали, got %s\n", $tmp); 22 23 if ("абра\\nкадабра" !== ($tmp = mysqli_real_escape_string($link, "абра\nкадабра"))) 24 printf("[007] Expecting абра\\nкадабра, got %s\n", $tmp); 25 26 if ("манда\\rин" !== ($tmp = mysqli_real_escape_string($link, "манда\rин"))) 27 printf("[008] Expecting \\r, got %s\n", $tmp); 28 29 if ("иху\\0аху" !== ($tmp = mysqli_real_escape_string($link, "иху" . chr(0) . "аху"))) 30 printf("[009] Expecting %s, got %s\n", "иху\\0аху", $tmp); 31 32 if (($exp='абра\\\\ка\"да\\'."'".'бра\Zсим\\nсала\\rби\\0м') !== 33 ($tmp = mysqli_real_escape_string($link, "абра\\ка\"да'бра\032сим\nсала\rби" . chr(0) . "м"))) 34 { 35 printf("[010] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); 36 } 37 38 if ('富\\\\酒吧' !== ($tmp = mysqli_real_escape_string($link, '富\\酒吧'))) 39 printf("[011] Expecting 富\\\\酒吧, got %s\n", $tmp); 40 41 if ('酒吧\"小题大做' !== ($tmp = mysqli_real_escape_string($link, '酒吧"小题大做'))) 42 printf("[012] Expecting 酒吧\"小题大做, got %s\n", $tmp); 43 44 if ("拉拉\'西雅图" !== ($tmp = mysqli_real_escape_string($link, "拉拉'西雅图"))) 45 printf("[013] Expecting 拉拉'西雅图, got %s\n", $tmp); 46 47 if ("阿卜拉\\n轻" !== ($tmp = mysqli_real_escape_string($link, "阿卜拉\n轻"))) 48 printf("[014] Expecting 阿卜拉\\n轻, got %s\n", $tmp); 49 50 if ("张明安\\r在" !== ($tmp = mysqli_real_escape_string($link, "张明安\r在"))) 51 printf("[015] Expecting 张明安\\r在, got %s\n", $tmp); 52 53 if ("竺可桢\\0空调器" !== ($tmp = mysqli_real_escape_string($link, "竺可桢" . chr(0) . "空调器"))) 54 printf("[016] Expecting %s, got %s\n", "竺可桢\\0空调器", $tmp); 55 56 if (($exp='阿卜拉\\\\嘉\"达丰\\'."'".'乳罩\Z辛\\n萨拉\\r毕\\0米') !== 57 ($tmp = mysqli_real_escape_string($link, "阿卜拉\\嘉\"达丰'乳罩\032辛\n萨拉\r毕" . chr(0) . "米"))) 58 { 59 printf("[017] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); 60 } 61 62 mysqli_close($link); 63 64 try { 65 mysqli_real_escape_string($link, 'foo'); 66 } catch (Error $exception) { 67 echo $exception->getMessage() . "\n"; 68 } 69 70 print "done!"; 71?> 72--CLEAN-- 73<?php 74 require_once("clean_table.inc"); 75?> 76--EXPECT-- 77mysqli object is already closed 78done! 79