Jump to content

video 3


zeusthegreat

Recommended Posts

index .php

 

 

 

<?php

define('APPLICATION_PATH', realpath('../'));

 

$paths = array(

APPLICATION_PATH,

APPLICATION_PATH . '/com',

get_include_path()

 

);

set_include_path(implode(PATH_SEPARATOR, $paths));

 

function _autoload($className)

{

$filename =str_replace('\\', '/' ,$className) . '.php';

require_once $filename;

 

}

 

//use \com\killerphp\models as models;

 

$User = new \com\killerphp\models\User();

echo $User->getName();

 

 

 

 

User.php (this being the class page)

 

 

<?php

namespace com\killerphp\models;

class User

{

public function getName()

{

return "John smith";

}

}

 

?>

 

returns from browser

 

 

Fatal error: Class 'com\killerphp\models\User' not found in C:\wamp\www\killerphp\public\index.php on line 21

 

 

 

this is probably something really easy i hope!!!

post-32686-045470300 1304691176_thumb.jpg

Link to comment
Share on other sites

done that sorry and i return the below error

 

 

 

 

 

Warning: require_once(com/killerphp/models/User.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\killerphp\public\video2\video3\index.php on line 15

 

Fatal error: require_once() [function.require]: Failed opening required 'com/killerphp/models/User.php' (include_path='C:\wamp\www\killerphp\public\video2;C:\wamp\www\killerphp\public\video2/com;.;C:\php5\pear') in C:\wamp\www\killerphp\public\video2\video3\index.php on line 15

Link to comment
Share on other sites

That error indicates that it can't find the file within the com/killerphp/models/ folders. Do you have that set up correctly? Is there a "User.php" file within that "models" folder?

 

Also (this may have nothing to do with the error) I noticed that you have the "video3" folder within the "video2" folder. I'm assuming that's done purposely? Just thought I would mention it in case that is causing a path issue.

 

C:\wamp\www\killerphp\public\video2\video3\index.php

Link to comment
Share on other sites

i have a folder called killerphp

 

in this folder is a folder called public

also in the killerphp folder is a folder called com

 

in the public folder is a file called index.php

 

<?php

define('APPLICATION_PATH', realpath('../'));

 

$paths = array(

APPLICATION_PATH,

get_include_path()

 

);

set_include_path(implode(PATH_SEPARATOR, $paths));

function __autoload($className)

{

$filename = str_replace('\\', '/', $className) . '.php';

require_once $filename;

return;

}

 

//use \com\killerphp\models as models;

 

//var_dump(get_include_path());

//require_once ('user.php');

$User = new \com\killerphp\models\User();

echo $User->getName();

 

 

 

 

 

 

?>

 

 

in the folder called com i have a folder called killerphp

 

 

and in the folder called killerphp i have a folder called models

 

 

and in the folder called models i have a file called user.php

 

 

<?php

namespace com\killerphp\models;

class User

{

public function getName()

{

return "John smith";

}

}

 

?>

 

 

 

am i doing it wrong placing the killerphp folder inside the com folder

Edited by talos
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...