Jump to content

Can't Get Script To Function


geno11x11

Recommended Posts

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>

Link to comment
Share on other sites

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 by Geno
Link to comment
Share on other sites

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 by Geno
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...