PSR-2 namespace issueHow does the keyword “use” work in PHP and can I import classes with it?Making a login screen using OOP PHPLogin script not workingPDO Cannot Connect to Remote MySQLPHP PDO connection to remote server connects to local server insteadPHP 7 DomDocument not foundPDO: database credentialsConnect to an SQLite database with PHPphp cannot find Class when using namespaceFatal error: Uncaught Error: Call to a member functionPSR-2 namespace Fatal error: Uncaught Error: Class 'Database' not found
What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?
The IT department bottlenecks progress, how should I handle this?
Giving feedback to someone without sounding prejudiced
15% tax on $7.5k earnings. Is that right?
Confused about Cramer-Rao lower bound and CLT
Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?
A Trivial Diagnosis
In a multiple cat home, how many litter boxes should you have?
Can I say "fingers" when referring to toes?
How do I fix the group tension caused by my character stealing and possibly killing without provocation?
Multiplicative persistence
Quoting Keynes in a lecture
How much theory knowledge is actually used while playing?
Make a Bowl of Alphabet Soup
Which was the first story featuring espers?
Is there a RAID 0 Equivalent for RAM?
Non-trope happy ending?
US tourist/student visa
Why does Carol not get rid of the Kree symbol on her suit when she changes its colours?
Why do ¬, ∀ and ∃ have the same precedence?
Change the color of a single dot in `ddot` symbol
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
Stack Interview Code methods made from class Node and Smart Pointers
Taxes on Dividends in a Roth IRA
PSR-2 namespace issue
How does the keyword “use” work in PHP and can I import classes with it?Making a login screen using OOP PHPLogin script not workingPDO Cannot Connect to Remote MySQLPHP PDO connection to remote server connects to local server insteadPHP 7 DomDocument not foundPDO: database credentialsConnect to an SQLite database with PHPphp cannot find Class when using namespaceFatal error: Uncaught Error: Call to a member functionPSR-2 namespace Fatal error: Uncaught Error: Class 'Database' not found
I added a namespace to my user.php file, this causes an error to be displayed :
Fatal error: Uncaught Error: Class 'User' not found in /var/www/html/login.php:9 Stack trace: #0 main thrown in
/var/www/html/login.php on line 9
I tried changing "new DatabaseDatabase();" to "new PDO();" but that causes another error which I've been unable to resolve after spending hours on google, if anyone could help I'd much appreciate it, thank you.
user.php
<?php
namespace User;
// 'user' object
class User
{
login.php
<?php
include_once "config/core.php";
$page_title = "Login";
$require_login = false;
include_once "login_checker.php";
include_once "config/database.php";
include_once "objects/user.php";
include_once "libs/php/pw-hashing/passwordLib.php";
$database = new DatabaseDatabase();
$db = $database->getConnection();
$user = new User($db);
php
|
show 4 more comments
I added a namespace to my user.php file, this causes an error to be displayed :
Fatal error: Uncaught Error: Class 'User' not found in /var/www/html/login.php:9 Stack trace: #0 main thrown in
/var/www/html/login.php on line 9
I tried changing "new DatabaseDatabase();" to "new PDO();" but that causes another error which I've been unable to resolve after spending hours on google, if anyone could help I'd much appreciate it, thank you.
user.php
<?php
namespace User;
// 'user' object
class User
{
login.php
<?php
include_once "config/core.php";
$page_title = "Login";
$require_login = false;
include_once "login_checker.php";
include_once "config/database.php";
include_once "objects/user.php";
include_once "libs/php/pw-hashing/passwordLib.php";
$database = new DatabaseDatabase();
$db = $database->getConnection();
$user = new User($db);
php
1
What exactly is the problem? Since the classUseris in the namespaceUser, it's fully qualified name isUserUser.
– tkausl
11 hours ago
Read the docs
– Xatenev
11 hours ago
@Xatenev - I've read the docs, but couldn't find the solution
– The_Linux_Box
11 hours ago
@tkausl - the problem is the error being displayed as mentioned in the post above, thank you
– The_Linux_Box
11 hours ago
1
Possible duplicate of How does the keyword "use" work in PHP and can I import classes with it?
– Xatenev
11 hours ago
|
show 4 more comments
I added a namespace to my user.php file, this causes an error to be displayed :
Fatal error: Uncaught Error: Class 'User' not found in /var/www/html/login.php:9 Stack trace: #0 main thrown in
/var/www/html/login.php on line 9
I tried changing "new DatabaseDatabase();" to "new PDO();" but that causes another error which I've been unable to resolve after spending hours on google, if anyone could help I'd much appreciate it, thank you.
user.php
<?php
namespace User;
// 'user' object
class User
{
login.php
<?php
include_once "config/core.php";
$page_title = "Login";
$require_login = false;
include_once "login_checker.php";
include_once "config/database.php";
include_once "objects/user.php";
include_once "libs/php/pw-hashing/passwordLib.php";
$database = new DatabaseDatabase();
$db = $database->getConnection();
$user = new User($db);
php
I added a namespace to my user.php file, this causes an error to be displayed :
Fatal error: Uncaught Error: Class 'User' not found in /var/www/html/login.php:9 Stack trace: #0 main thrown in
/var/www/html/login.php on line 9
I tried changing "new DatabaseDatabase();" to "new PDO();" but that causes another error which I've been unable to resolve after spending hours on google, if anyone could help I'd much appreciate it, thank you.
user.php
<?php
namespace User;
// 'user' object
class User
{
login.php
<?php
include_once "config/core.php";
$page_title = "Login";
$require_login = false;
include_once "login_checker.php";
include_once "config/database.php";
include_once "objects/user.php";
include_once "libs/php/pw-hashing/passwordLib.php";
$database = new DatabaseDatabase();
$db = $database->getConnection();
$user = new User($db);
php
php
edited 9 hours ago
Tomka Koliada
1,1821828
1,1821828
asked 11 hours ago
The_Linux_BoxThe_Linux_Box
144
144
1
What exactly is the problem? Since the classUseris in the namespaceUser, it's fully qualified name isUserUser.
– tkausl
11 hours ago
Read the docs
– Xatenev
11 hours ago
@Xatenev - I've read the docs, but couldn't find the solution
– The_Linux_Box
11 hours ago
@tkausl - the problem is the error being displayed as mentioned in the post above, thank you
– The_Linux_Box
11 hours ago
1
Possible duplicate of How does the keyword "use" work in PHP and can I import classes with it?
– Xatenev
11 hours ago
|
show 4 more comments
1
What exactly is the problem? Since the classUseris in the namespaceUser, it's fully qualified name isUserUser.
– tkausl
11 hours ago
Read the docs
– Xatenev
11 hours ago
@Xatenev - I've read the docs, but couldn't find the solution
– The_Linux_Box
11 hours ago
@tkausl - the problem is the error being displayed as mentioned in the post above, thank you
– The_Linux_Box
11 hours ago
1
Possible duplicate of How does the keyword "use" work in PHP and can I import classes with it?
– Xatenev
11 hours ago
1
1
What exactly is the problem? Since the class
User is in the namespace User, it's fully qualified name is UserUser.– tkausl
11 hours ago
What exactly is the problem? Since the class
User is in the namespace User, it's fully qualified name is UserUser.– tkausl
11 hours ago
Read the docs
– Xatenev
11 hours ago
Read the docs
– Xatenev
11 hours ago
@Xatenev - I've read the docs, but couldn't find the solution
– The_Linux_Box
11 hours ago
@Xatenev - I've read the docs, but couldn't find the solution
– The_Linux_Box
11 hours ago
@tkausl - the problem is the error being displayed as mentioned in the post above, thank you
– The_Linux_Box
11 hours ago
@tkausl - the problem is the error being displayed as mentioned in the post above, thank you
– The_Linux_Box
11 hours ago
1
1
Possible duplicate of How does the keyword "use" work in PHP and can I import classes with it?
– Xatenev
11 hours ago
Possible duplicate of How does the keyword "use" work in PHP and can I import classes with it?
– Xatenev
11 hours ago
|
show 4 more comments
1 Answer
1
active
oldest
votes
use UserUser;
$user = new User($db);
3
Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!
– Eel Lee
10 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280034%2fpsr-2-namespace-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
use UserUser;
$user = new User($db);
3
Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!
– Eel Lee
10 hours ago
add a comment |
use UserUser;
$user = new User($db);
3
Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!
– Eel Lee
10 hours ago
add a comment |
use UserUser;
$user = new User($db);
use UserUser;
$user = new User($db);
answered 11 hours ago
Николай ЛубышевНиколай Лубышев
44948
44948
3
Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!
– Eel Lee
10 hours ago
add a comment |
3
Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!
– Eel Lee
10 hours ago
3
3
Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!
– Eel Lee
10 hours ago
Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!
– Eel Lee
10 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280034%2fpsr-2-namespace-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What exactly is the problem? Since the class
Useris in the namespaceUser, it's fully qualified name isUserUser.– tkausl
11 hours ago
Read the docs
– Xatenev
11 hours ago
@Xatenev - I've read the docs, but couldn't find the solution
– The_Linux_Box
11 hours ago
@tkausl - the problem is the error being displayed as mentioned in the post above, thank you
– The_Linux_Box
11 hours ago
1
Possible duplicate of How does the keyword "use" work in PHP and can I import classes with it?
– Xatenev
11 hours ago