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













0















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);









share|improve this question



















  • 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











  • 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















0















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);









share|improve this question



















  • 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











  • 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













0












0








0


1






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);









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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











  • @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





    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











  • @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












1 Answer
1






active

oldest

votes


















-1














use UserUser;
$user = new User($db);





share|improve this answer


















  • 3





    Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!

    – Eel Lee
    10 hours ago










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
);



);













draft saved

draft discarded


















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









-1














use UserUser;
$user = new User($db);





share|improve this answer


















  • 3





    Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!

    – Eel Lee
    10 hours ago















-1














use UserUser;
$user = new User($db);





share|improve this answer


















  • 3





    Hi, it would be nice to provide some context and/or explanation to this snippet. Thank you!

    – Eel Lee
    10 hours ago













-1












-1








-1







use UserUser;
$user = new User($db);





share|improve this answer













use UserUser;
$user = new User($db);






share|improve this answer












share|improve this answer



share|improve this answer










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












  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해