Results 1 to 16 of 16
May 18, 2013, 04:01 #1
- Join Date
- Sep 2008
- Manchester, UK
- 10 Post(s)
- 0 Thread(s)
Strange Characters Displaying with OOP PHP
Just trying out some very simple OOP PHP and some funny characters are being displayed on the page for what seems to be no apparent reason!
I've got two PHP files: A class file which is just PHP and a PHP file which contains HTML and calls the method from the class. Here are the two files I have:
// Property AKA Variable Declaration
public $bookTitle = 'Dracula';
public $bookSlug = '';
public $bookAuthor = '';
public $bookPublisher = '';
public $bookGenreSubject = '';
public $bookRating = '';
public $bookISBN = '';
public $bookPrice = '';
public function __construct()
// $this->bookTitle = $bookTitle;
// Method AKA Function Declaration
public function setBookTitle($bookTitle)
$this->bookTitle = $bookTitle;
public function getBookTitle()
<?php include_once("includes/book.class.php") ?> <?php $title = new Book(); ?> <!DOCTYPE html> <html> <head> <title><?php echo $title->getBookTitle(); ?></title> </head> <body> <article> <header> <h1><?php echo $title->getBookTitle(); ?></h1> </header> </article> </body> </html>
What the bloody hell is going on here? I don't have a clue! All that should be on this page is "Dracula" wrapped in the h1 tags.
And when I go directly to the book.class.php page it always displays this:
Should the class be displaying anything in the browser like that?
Any ideas? Help would be appreciated, thanks.