geno11x11 Posted February 3, 2013 Report Share Posted February 3, 2013 I am new to mysqli so I've been hitting the tutorials. I am following Stefan Mischook's OOP tutorial http://www.killerphp.com/tutorials/object-oriented-php/ and I am stuck on his example in Building OOP objects part 2. I've definitely invested the time trying to figure this out; I wonder if there is a PHP configuration missing on my installation. Any help would be greatly appreciated... The output is supposed to be Stefan but I get get_name(); ?> My code for class_lib.php: <?php class person { var $name = "stefan"; function get_name() { return $this->name; } } ?> My code for index.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php include("class_lib.php"); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Killer Index.php</title> </head> <body> <?php $stefan = new person(); echo $stefan->get_name(); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted February 3, 2013 Report Share Posted February 3, 2013 I've tested your code on my own machine, and I'm not having any problems. After running that code I get "stefan". What sort of server setup are you using? WAMP? MAMP? Something else? As far as I know, this code should work the same and you shouldn't need to modify any settings for this to work. Quote Link to comment Share on other sites More sharing options...
geno11x11 Posted February 3, 2013 Author Report Share Posted February 3, 2013 (edited) Actually, that is great news - probably a system issue then. I'm using LAMP; OpenSuse11.3, Apache2.2.15 MySQL5.1.57 and PHP5.3.3. I suspect a configuration problem or maybe a missing extension because I can't get other PHP commands to work, such as mysqli_connect_error(). I am putting off a few obvious upgrades because I am right in the middle of a project, but if that is necessary to get things working, I'll make the jump. Edited February 3, 2013 by Geno Quote Link to comment Share on other sites More sharing options...
geno11x11 Posted February 3, 2013 Author Report Share Posted February 3, 2013 (edited) Problem solved!!! I had a hunch and did a cut-and-paste of my scripts from this website to my editor, replaced the old files, and it worked -- I'm thinking now that hidden characters from my editor are to blame. That would explain a whole slew of unexpected and unsuccessful results over the past week. I have been using G-edit on Linux and Dreamweaver on Windows; I wouldn't think Dreamweaver would be responsible, so I'll be looking for a new Linux text editor. Any suggestions? Edited February 3, 2013 by Geno Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.