php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53945 Self descriptive
Submitted: 2011-02-07 10:16 UTC Modified: 2011-02-07 12:48 UTC
From: knight_adi2000 at yahoo dot com Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: Irrelevant OS: Windows Vista ultimate
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: knight_adi2000 at yahoo dot com
New email:
PHP Version: OS:

 

 [2011-02-07 10:16 UTC] knight_adi2000 at yahoo dot com
Description:
------------
---
From manual page: http://www.php.net/language.exceptions
---
Notice the line 
if($throw_exception === 1) throw new Excepion('Exception thrown.<br>');
has Excepion NOT Exception word inside the code .
This is not detected by the compiler when compiling the code , unless you set the 
value Int 1 as parameter, in order to make the function throw the error , and 
there is no class that i defined as Excepion , it can be replaced with any class 
not only Excepion (Not Exception) .
Unless the function is made to throw an Exception, it does not detect that the 
actual object simply does NOT exist(in this case the object caled Excepion) .
Be carefull with writing your code .

Test script:
---------------
<?php
function test_compiler($throw_exception)
{
try {
		if($throw_exception === 1) throw new Excepion('Exception thrown.<br>');
	}
catch(Exception $exception)
	{
	echo "Error caught from test_compiler". $exception->getMessage();
	}
	return 1;
}
echo test_compiler(2);
?>

Expected result:
----------------
When i set the $throw_exception to other value than 1 integer type, the compiler 
should detect that the Excepion (NOT Exception ) object does NOT exist .


Actual result:
--------------
The compiler detects that the Excepion object DOES NOT exist ONLY IF the value is 
set to integer 1 , than and only than the compiler works right in this case .
Please Php Staff take this into your atention .
Thank you .

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-07 12:48 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2011-02-07 12:48 UTC] johannes@php.net
PHP does not require types to be declared at compile time. Code like this is absolutely valid:

main.php:
<?php
for ($i = 0; $i < 10; ++$i) {
    include "$i.php";
    if ($throw == 1) throw new Excepion('Exception thrown.<br>');
}

an then in 5.php or so:
<?php
class Excepion extends Exception {}

Or there's __autoload ...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 20:01:35 2025 UTC