Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'namespaces'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 2 results

  1. In the "Namespaces" section in Ch.6, Larry describes how the use keyword can allow us to reference a namespace once in our script so that we don't need to name the specific namespace over and over again when we make objects: Unfortunately, I am getting a class not found error when I try to use this. See program below, a shorter version of the type hinting example used earlier in the book. Company.php <?php namespace MyNamespace\Company; class Department{ private $_name; private $_employees; function __construct($name){ $this->_name = $name; $this->_employees = array(); }//__construct function addEmployee(Employee $e){ $this->_employees[] = $e; echo "<p>{$e->getName()} has been added to the {$this->_name} department.</p>"; }//addEmployee }//Department class Employee{ private $_name; function __construct($name){ $this->_name = $name; } function getName(){ return $this->_name; }//getName }//Employee ?> Using use in a separate file in the same directory as Company.php: <?php require('Company.php'); use MyNamespace\Company; $hr = new Department("Human Resources"); $e1 = new Employee("mary"); $hr->addEmployee($e1); ?> The code above generates a fatal error: "Fatal error: Class 'Department' not found" Am I missing something or am I not using use properly? Any assistance is greatly appreciated.
  2. Hey, everyone. Working on a pluginen for Wordpress right now. It will allow you to comment articles as a phpBB3 user. The problem has to do with phpBB3s native session solution. By including the file "common.php" and doing some authentification against phpBB3, you'll have support for phpBB3 sessions outside of the forum solution. The problem is that both phpBB3 and Wordpress are polluting the global namespace. Global variables such as $db, $theme, etc, is used by both system. We also have function naming conflicts. Functions are pretty manageable. Because I can run those few functions I need inside my own classes, this works fine. The problem is those global variables that crash WP when included from phpBB3. Is there a way to unset the global variables or a way to use PHPs new namespaces to solve this issue? I guess both PHP and JavaScript developers might be able to answer me that.
×
×
  • Create New...