Added missing object support to file_put_contents().

This commit is contained in:
Ilia Alshanetsky 2006-11-15 00:20:40 +00:00
parent 6640a1c861
commit fca0e24410
2 changed files with 16 additions and 3 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2007, PHP 5.2.1
- Added missing object support to file_put_contents(). (Ilia)
- Updated bundled libcURL to version 7.16.0 in the Windows distro. (Edin)
- cgi.* and fastcgi.* directives are moved to INI subsystem.
The new directive cgi.check_shebang_line can be used to ommiting checnk

View File

@ -653,11 +653,23 @@ PHP_FUNCTION(file_put_contents)
}
break;
case IS_OBJECT:
if (Z_OBJ_HT_P(data) != NULL) {
zval out;
if (zend_std_cast_object_tostring(data, &out, IS_STRING TSRMLS_CC) == SUCCESS) {
numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out));
if (numbytes != Z_STRLEN(out)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out));
numbytes = -1;
}
zval_dtor(&out);
break;
}
}
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The 2nd parameter should be either a string or an array");
numbytes = -1;
numbytes = -1;
break;
}
php_stream_close(stream);