Hi folks,
I'm kind of stressed out right now about this class I'm taking, PHP and MySQL...for beginners :)
Anyways, he has us read the Murach PHP and MySQL, and then afterwords we are to write code for an assignment.
This week I had to create two files: book.php and processBookType.php.
In the book.php I have to:
Create a "Book" class
Name the file “book.php”.
Add a public method “displayBookTitle()”.
Accept $_POST array as single argument.
Make use of an “if / else” statement along with isset() and empty() to check if the book title is available.
Echo an appropriate error message when desired condition is not met.
Concatenate the book title retrieved from the $_POST array to this string: “The following book was submitted: “
Echo the concatenated string.
In the processBookTitle.php I need to:
Make use of “include()” function to reference Book class.
Create a Book object.
Call the Book Object’s “displayBookTitle()” method.
Pass in the $_POST array as single argument.
This is my code for book.php:
<?php
class Book {
public function getdisplayTitle('title') {
$displayTitle = $_POST['title'];
if(isset($_POST['title'])) {
$title=$_POST['title']; }
if(empty($title)) {
echo 'Need Book Title'; }
else {echo '<p> "The following book was submitted: "' . $title . '</p>'; }
return $displayTitle;
}
}
?>
And this is my code for processBookTitle.php:
<?php
include('book.php');
$publisher = new Book ('name', 'location');
$publisher->name = '';
echo $publisher->name;
$publisher->location = '';
echo $publisher->location;
$publisher->displayTitle ($_POST);
?>
The error I get:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '&' or T_VARIABLE in C:\xampp\htdocs\assignment\book.php on line 3
So, does anyone know what I'm doing wrong? The instructor (at a University) says I should be able to figure it out myself. This is all new to me so I don't know. Have worked on it a few days.
Thanks for any input.
Apparently the string is suppose to output to book.php file? That is unclear to me also.