Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19076 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2543 invoked by uid 1010); 19 Sep 2005 15:18:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 2528 invoked from network); 19 Sep 2005 15:18:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2005 15:18:15 -0000 X-Host-Fingerprint: 64.233.162.196 zproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.162.196:47834] helo=zproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id FD/8D-43379-6B6DE234 for ; Mon, 19 Sep 2005 11:18:14 -0400 Received: by zproxy.gmail.com with SMTP id z31so243152nzd for ; Mon, 19 Sep 2005 08:18:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=O64pOi15epp8+fcz5KpVfaXXJY/Ve5mGRdsEQo3vKiKB8OJh/HEzW2b1DEt9eWwWQyEyvvftxo2if8j/ydx9Hc8th3+txksvnB4X/VWAkQ52WN7ZGdBmAT5HsXkjZAMtt9grDIvQ/QxCf8pEiz4MU1S2k/FC5SnvI6I8qpSJs2U= Received: by 10.36.59.14 with SMTP id h14mr2083047nza; Mon, 19 Sep 2005 08:18:10 -0700 (PDT) Received: by 10.36.147.14 with HTTP; Mon, 19 Sep 2005 08:18:10 -0700 (PDT) Message-ID: <5c287472050919081831930aea@mail.gmail.com> Date: Mon, 19 Sep 2005 10:18:10 -0500 Reply-To: jason.sweat@gmail.com To: internals@lists.php.net Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: unable to create class from constant From: jason.sweat@gmail.com (Jason Sweat) I ran across this today and it surprised me: $ php -r 'define("X", "stdClass"); $x =3D new X; var_dump($x);'; Fatal error: Cannot instantiate non-existent class: x in Command line code on line 1 I tested on php 4.4.0, 4.3.8 and 5.0.3, with the result that all versions exhibit the same behavior. Clearly there is an easy work around: $ php -r 'define("X", "stdClass"); $y =3D X; $x =3D new $y; var_dump($x);' object(stdClass)(0) { } But I was wondering if anyone could enlighten me as to why php would be upset interpreting the constant as the class name. Thanks. =20 Regards, Jason http://blog.casey-sweat.us/