php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71044 Get class datetime
Submitted: 2015-12-06 17:26 UTC Modified: 2015-12-06 21:36 UTC
From: fabien dot papet at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.5.30 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fabien dot papet at gmail dot com
New email:
PHP Version: OS:

 

 [2015-12-06 17:26 UTC] fabien dot papet at gmail dot com
Description:
------------
Get class and ::class different are not equal. (at least for Datetime object)

http://stackoverflow.com/questions/34118725/diffence-between-class-and-get-class

Test script:
---------------
<?php
// PHP 5.5
var_dump(get_class(new Datetime())); // string(8) "DateTime" 
var_dump(Datetime::class); // string(8) "Datetime" with lower t


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-06 21:36 UTC] danack@php.net
-Status: Open +Status: Not a bug
 [2015-12-06 21:36 UTC] danack@php.net
The '::class' construct is done purely at compile time, based of the apparent classname passed in. It does not check the spelling of the actual class name, or even that the class exists e.g.

echo dAtEtImE::class;

Output is "dAtEtImE"


echo ThisDoesNotExist::class;

Output is "ThisDoesNotExist"

i.e. if you want var_dump(Datetime::class); to output a capital T, then spell it with a capital T.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 16:01:38 2025 UTC