Note that there are some explanatory texts on larger screens.

plurals
  1. POConfused with php namespaces
    primarykey
    data
    text
    <p>I've got the following structure in my app:</p> <pre><code>| |----user folder | | | |-----Member.php | | | |---- tests Folder | | | |-----Member.php </code></pre> <p>Here is my <code>Member.php</code> in user folder:</p> <pre><code>&lt;?php namespace user; class Member { private $firstName; private $lastName; private $email; private $password; private $cell; public function __construct() { } public function getFirstName() { return $this-&gt;firstName; } public function setFirstName($firstName) { $this-&gt;firstName = $firstName; return TRUE; } public function getLastName() { return $this-&gt;lastName; } public function setLastName($lastName) { $this-&gt;lastName = $lastName; return TRUE; } public function getEmail() { return $this-&gt;email; } public function setEmail($email) { $this-&gt;email = $email; return TRUE; } public function getPassword() { return $this-&gt;password; } public function setPassword($password) { $this-&gt;password = $password; return TRUE; } public function getCell() { return $this-&gt;cell; } public function setCell($cell) { $this-&gt;cell = $cell; return TRUE; } } </code></pre> <p>And here is my Member.php in tests folder:</p> <pre><code>&lt;?php /* * Member class getters and setters tests */ namespace user; use user; $member = new Member(); $member-&gt;setFirstName("Javad"); if($member-&gt;getFirstName() == "Javad") echo "Test code 1 passed"; else echo "Test code 1 failed"; $member = new Member(); $member-&gt;setLastName("Akbari"); if($member-&gt;getLastName() == "Akbari") echo "Test code 2 passed"; else echo "Test code 2 failed"; $member = new Member(); $member-&gt;setEmail("j2omrani@gmail.com"); if($member-&gt;getEmail() == "j2omrani@gmail.com") echo "Test code 3 passed"; else echo "Test code 3 failed"; $member = new Member(); $member-&gt;setPassword("123456"); if($member-&gt;getPassword() == "123456") echo "Test code 4 passed"; else echo "Test code 4 failed"; $member = new Member(); $member-&gt;setCell("09121234567"); if($member-&gt;getCell() == "09121234567") echo "Test code 5 passed"; else echo "Test code 5 failed"; </code></pre> <p>When I want to create an Object it throws exception and says:</p> <pre><code>Fatal error: Class 'user\Member' not found in C:\xampp\htdocs\auto24\user\tests\Member.php on line 8 </code></pre> <p>My question is how can I call the Member Object in the tests folder files using namespaces?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload