php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51013 use namespace in eval
Submitted: 2010-02-11 11:53 UTC Modified: 2010-02-11 13:21 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: dellytufy at hotmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.3SVN-2010-02-11 (SVN) OS: win
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: dellytufy at hotmail dot com
New email:
PHP Version: OS:

 

 [2010-02-11 11:53 UTC] dellytufy at hotmail dot com
Description:
------------
i cannot use namespace in eval() 
as
eval('use namespaceName\classname as  myClass;');

after this  i cannot ust  $mc=myClass();  undeclared class

namespace d3;
    namespace d3\sql;
        class oracle{
             public $type='oracle';
        } 

         
       namespace d3\linq;
       class linq{
           public $className='linq';
       }


$type='oracle';    
   eval('use \d3\sql\\'.$type.' as baglanti;');
   $a=new baglanti();// error. undeclared class  d3\linq\baglanti
   echo $a->type; 

Reproduce code:
---------------
$type='oracle';    
   eval('use \d3\sql\\'.$type.' as baglanti; $a=new baglanti();');
   echo $a->type; 

but this is successfully runned.

Expected result:
----------------
namespace d3;
    namespace d3\sql;
        class oracle{
             public $type='oracle';
        } 

         
       namespace d3\linq;
       class linq{
           public $className='linq';
       }


$type='oracle';    
   eval('use \d3\sql\\'.$type.' as baglanti;');
$a=new baglanti();
  echo $a->type; 

i think it must write oracle .


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-11 12:11 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The use in the eval() is valid for the eval\'d code.
 [2010-02-11 13:21 UTC] dellytufy at hotmail dot com
thanx i will check again

but 

why  it's running 
eval('use \d3\sql\\'.$type.' as baglanti; $a=new baglanti();');


it's not
eval('use \d3\sql\\'.$type.' as baglanti;');
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 04 12:00:02 2025 UTC