php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52059 get_class() throws warning instead of false on non-object vars
Submitted: 2010-06-11 23:45 UTC Modified: 2010-06-12 21:46 UTC
From: shawn at thesignchef dot com Assigned: markskilbeck (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.2 OS: Linux ip-10-251-67-133 2.6.21.7
Private report: No CVE-ID: None
 [2010-06-11 23:45 UTC] shawn at thesignchef dot com
Description:
------------
get_class() throws warning instead of false on non-object vars.

Per documentation, it is supposed to just return false.

Test script:
---------------
$foo = "test";

get_class($foo); // throws E_WARNING

Expected result:
----------------
For the function to simply return false without throwing an E_WARNING

Actual result:
--------------
get_class() expects parameter 1 to be object, string given

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-12 21:46 UTC] markskilbeck@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: markskilbeck
 [2010-06-12 21:46 UTC] markskilbeck@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Actually, get_class() does return FALSE on error. It also raises an error, as 
you have said.

[code]
<?php

var_dump(get_class(array()));
[/code]

I have updated get_class()'s documentation to include this information.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 09:00:02 2026 UTC