php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14406 typeof operator
Submitted: 2001-12-10 10:44 UTC Modified: 2003-01-18 13:19 UTC
From: foobardotcom at poczta dot onet dot pl Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.1.0 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: foobardotcom at poczta dot onet dot pl
New email:
PHP Version: OS:

 

 [2001-12-10 10:44 UTC] foobardotcom at poczta dot onet dot pl
First part of code is the same in every way:

class Foo {}
$o = new Foo();

Now there is:

if (get_class($o) == "foo") {
  // ok
} else {
  // not ok
}

I can create walkaround:

function typeof(&$obj, $classname) {
  return (get_class($obj) == strtolower(trim($classname)));
}

if (typeof($o, "Foo"))) {
  // ok
} else {
  // not ok
}

You should make it easier, by new `typeof' operator:

if ($o typeof Foo) {
  // ok
} else {
  // not ok
}

like in JavaScript.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-18 13:19 UTC] andrey@php.net
 There will be "instanceof" in PHP5.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 16:01:27 2024 UTC