}
/* }}} */
-/* {{{ proto string|false wordwrap(string str [, int width [, string break [, bool cut]]])
+/* {{{ proto string wordwrap(string str [, int width [, string break [, bool cut]]])
Wraps buffer to selected number of characters using string break char */
PHP_FUNCTION(wordwrap)
{
}
if (breakchar_len == 0) {
- php_error_docref(NULL, E_WARNING, "Break string cannot be empty");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Break string cannot be empty");
+ return;
}
if (linelength == 0 && docut) {
- php_error_docref(NULL, E_WARNING, "Can't force cut when width is zero");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Can't force cut when width is zero");
+ return;
}
/* Special case for a single-character break as it needs no
"123|==1234567890|==123" === wordwrap("123 1234567890 123", 10, "|==", 1)
-FALSE === @wordwrap(chr(0), 0, "")
-
TESTS;
include(__DIR__ . '/../../../../tests/quicktester.inc');
+
+echo "\n";
+
+try {
+ wordwrap(chr(0), 0, "");
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
--EXPECT--
OK
+Break string cannot be empty
// width as zero and cut as true
$width = 0;
$cut = true;
-var_dump( wordwrap($str, $width, $break, $cut) );
+
+try {
+ wordwrap($str, $width, $break, $cut);
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
echo "-- width = -10 & cut = false --\n";
// width as -ne and cut as false
-- width = 0 & cut = false --
string(39) "testing<br />\nwordwrap<br />\nfunction"
-- width = 0 & cut = true --
-
-Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
-bool(false)
+Can't force cut when width is zero
-- width = -10 & cut = false --
string(39) "testing<br />\nwordwrap<br />\nfunction"
-- width = -10 & cut = true --