php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #20182 Importing symbols from one class to another
Submitted: 2002-10-31 01:49 UTC Modified: 2004-01-17 10:20 UTC
From: scotje at wwc dot edu Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.3.0-pre2 OS: Debian 3.0
Private report: No CVE-ID: None
 [2002-10-31 01:49 UTC] scotje at wwc dot edu
I am encountering a parse error when I try to import symbols from one class into another class.

Here's my example:

<?php

class rztest
{
        const testvar = 1;

        function test()
        {
                echo "This is a test.";
        }
}

class rztest2
{
        import const testvar from rztest;

        function test2()
        {
                echo testvar;
        }

}
?>

The import line in the rztest2 class results in:

Parse error: parse error, expecting `';'' in /home/jesse/public_html/test.php on line 15

If I comment out the import line it runs without complaint.    I am also able to access the constant just fine by using a direct rztest::testvar reference.  I also tried importing the function from rztest instead of the constant and had similar results.

I have no difficulty importing a constant or function into the global scope.

I am currently using the packaged php4.3.0-dev w/ zend engine 2 that was released in June because I haven't been able to make the current php4-ze2 cvs branch compile yet.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-17 10:20 UTC] andrey@php.net
"import" is no more part of PHP5
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Aug 18 18:00:03 2025 UTC