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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 18:01:31 2024 UTC