namespace definition problem
Posted: Sun Mar 26, 2017 6:37 pm
Hi,
I am getting this error. I dont know how to troubleshoot it. I am using Windows 8.1 machine.
Fatal error: Uncaught Error: Class 'xampp\php\pear\Product' not found in F:\xampp\htdocs\brackets-dev\index.php:11 Stack trace: #0 {main} thrown in F:\xampp\htdocs\brackets-dev\index.php on line 11
I have a class called Product in F:\xampp\php\pear\Product.php
include_path=F:\xampp\php\PEAR (php.ini)
I clearly have a issue with namespace definition and possibly use xampp\php\pear\Product
I have tried many things. Googling a lot... and nothing.
Help would be much much appreciated.
Thank you.
I am getting this error. I dont know how to troubleshoot it. I am using Windows 8.1 machine.
Fatal error: Uncaught Error: Class 'xampp\php\pear\Product' not found in F:\xampp\htdocs\brackets-dev\index.php:11 Stack trace: #0 {main} thrown in F:\xampp\htdocs\brackets-dev\index.php on line 11
I have a class called Product in F:\xampp\php\pear\Product.php
include_path=F:\xampp\php\PEAR (php.ini)
Code: Select all
<?php
namespace \php\pear; # convencion: nombre NAMESPACE = nombre CARPETA contenedora
class Product # convencion: nombre CLASE = nombre ARCHIVO
{
protected $name;
public function __construct($name)
{
$this->name = $name;
}
}[/b]
I am trying to instantiate this class in index.php which is in F:\xampp\htdocs\brackets-dev\index.php contains this code.
[b]<?php
include 'Product.php';
use xampp\php\pear\Product;
$product_one = new Product('colador');I have tried many things. Googling a lot... and nothing.
Help would be much much appreciated.
Thank you.