Jump to content

TomTees

Members
  • Posts

    187
  • Joined

  • Last visited

    Never

Posts posted by TomTees

  1. Try these settings:

     

    	// Constants
    define('BASE_URI', '/01_KnowledgeIsPower/');
    define('BASE_URL', 'localhost');
    define('MYSQL', '/includes/mysql.inc.php');

     

    It's a bit tricky to know what they're expecting there, as those are not what I would normally consider a URI or URL.  So instead I'm trying to go based on the example values.

     

    What they are expecting was documented in my original post.

     

    I tried your idea above but it doesn't seem to work.

     

    config.inc.php

    define('BASE_URL', 'localhost');

     

     

    index.php

    <?php
    include (BASE_URL . '/includes/footer.html');
    ?>

     

     

    Yields this error...

    Warning: include(localhost/includes/footer.html) [function.include]: failed to open stream: No such file or directory in /Users/user1/Documents/DEV/++htdocs/01_KnowledgeIsPower/index.php on line 23

    Call Stack

    # Time Memory Function Location

    1 0.0012 56064 {main}( ) ../index.php:0

     

     

    TomTees

     

     

  2. Well, there's your problem.  You need a .php page in order for the php engine to recognize it's a page to be rendered by PHP.  Change the extension from .html to .php and you'll see it in the title.

     

    Maybe your author was/is going to have the header as an include?  i.e. have an index.php page and inside that page do

    include('header.php');

    or

    include_once('header.php');

     

    Yeah, I figured that out while you guys were responding.  I placed the code in test.php and it ran/looks fine.

     

    The author is indeed making me create a header.html file that will ultimately be included in a php file but I'm not that far in my book yet!  :D

     

    Thanks,

     

     

     

    TomTees

     

    P.S.  Feel free to answer this post if you know the answer...

     

    http://www.phpfreaks.com/forums/php-coding-help/help-setting-up-path-constants/

     

     

     

  3. Does your webpage end in .php?  i.e. index.php, page.php, etc.?

     

    Is the PHP engine supplied to you?  Are you using a 'free webhosting' website?  If so, what company?

     

    Your code is correct, though I'm not a fan of your formatting (then again we each have our own style).

     

    I am using NetBeans on my laptop.

     

    The author said to call the page "header.html"

     

    What is wrong with my formatting?

     

     

    TomTees

     

     

  4. I am trying to set the HTML Page Title dynamically, but this code from my book doesn't work...

     

    			<title>
    			<?php
    				// Dynamically set Page Title.
    				if (isset($page_title)){
    					echo $page_title;
    				} else {
    					// Default Page Title.
    					echo 'Knowledge is Power: And It Pays To Know';
    				}
    			?>
    		</title>
    

     

    What is wrong with it?

     

    (All I see is the code in the Webpage/Window Title...)

     

     

     

    TomTees

     

     

  5. I am following a book and need help setting up Path Constants.

     

    Here is the script I need to adjust...

     

    	// Constants
    define('BASE_URI', '/path/to/Web/parent/folder/');
    define('BASE_URL', 'www.example.com');
    define('MYSQL', '/path/to/mysql.inc.php');
    

    Since I am working in NetBeans, I do not have access above my Project Folder which serves as my "Web Root".

     

    So if my Project Folder is called "MyProjectFolder", and I want both BASE_URI and BASE_URL to point to that directory on my laptop, what should I put?

     

    I'm thinking something like this...

     

    	// Constants
    define('BASE_URI', '/');
    define('BASE_URL', '/');
    define('MYSQL', '/includes/mysql.inc.php');
    

     

     

     

    TomTees

     

     

  6. 1.) Is it correct that in the array above, the KEY is a book name and the VALUE is an object?

     

    Your duplicating data this way. I would make it a simple numerically indexed array.

     

    I'm just working off a tutorial on MVC and trying to understand it.

     

    http://php-html.net/tutorials/model-view-controller-in-php/

     

     

    2.) What is the name of the array above?

     

    Arrays don't have names. They can be stored in variables, but I'm not sure that is what you mean.

     

    I'm used to seeing array being assigned to a variable when they are created.

     

     

    TomTees

     

  7. Why not give the anonymous array a name like this...

     

    class Model {

    public function getBookList()

    {

    $myArray = array(

    "Jungle Book" => new Book("Jungle Book", "R. Kipling", "A classic book."),

    "Moonwalker" => new Book("Moonwalker", "J. Walker", ""),

    "PHP for Dummies" => new Book("PHP for Dummies", "Some Smart Guy", "")

    );

    return $myArray;

    }

    }

     

     

    TomTees

     

  8. In this code...

     

    class Model {

    public function getBook($title)

    {

    $allBooks = $this->getBookList();

    return $allBooks[$title];

    }

    }

     

     

    Questions:

    ---------------

    1.) What is the scope of $allBooks?

     

    Can it be seen outside the function and inside the class?

     

    2.) Could I rewrite things like this...

     

    class Model {

    protected $allBooks;

     

    public function getBook($title)

    {

    $allBooks = $this->getBookList();

    $this->allBooks = $this->getBookList();

    return $allBooks[$title];

    }

    }

     

     

    3.) Sorta off-topic, but could I rewrite this code...

     

    $allBooks = $this->getBookList();

    return $allBooks[$title];

     

    like this...

     

    return $allBooks = $this->getBookList([$title]);

     

     

     

    TomTees

     

     

  9. I have a question about the array in this code...

     

    class Model {

    public function getBookList()

    {

    return array(

    "Jungle Book" => new Book("Jungle Book", "R. Kipling", "A classic book."),

    "Moonwalker" => new Book("Moonwalker", "J. Walker", ""),

    "PHP for Dummies" => new Book("PHP for Dummies", "Some Smart Guy", "")

    );

    }

    }

     

    class Book {

    public $title;

    public $author;

    public $description;

     

    public function __construct($title, $author, $description) 

        { 

    $this->title = $title;

        $this->author = $author;

        $this->description = $description;

        }

    }

     

     

    Questions:

    --------------

    1.) Is it correct that in the array above, the KEY is a book name and the VALUE is an object?

     

    2.) What is the name of the array above?

     

     

    TomTees

     

     

     

  10. Noticed a LOT of small questions regarding different parts of more advanced PHP from Tom - might I advise you buy yourself a few decent books and read them. You can get the answer to this question within 10 seconds if you search google.

     

    Here's a link to another thread regarding good PHP books:

     

    http://www.phpfreaks.com/forums/miscellaneous/good-programming-and-web-design-books/

     

    Hope that helps.

     

    Thanks for the link, but the reason I am here online is becasue books only go so far...

     

     

    TomTees

     

  11. Namespaces are a .net concept.  With that said, I guess you could use includes to try and get the same result.

     

    Namespaces may not be a PHP concept, but they are certainly not just limited to .Net so I wouldn't say "they are a .Net concept".  (Maybe you were just saying that in context?)

     

    I believe they are used also in C, C++, Java, and so on.

     

     

     

    TomTees

     

     

  12. A 'view' is the part of the MVC that produces output. 'View Scripts' are basically like templates that can also contain 'View Helpers'. These are typically gathered and processed via a 'View' object, which in turn passes output to the 'Response' object.

     

    Hey, don't make this even more complicated?!  :o

     

    Can you give me a simple example of a 'View Script'?

     

    Can you give me an example 'View Helpers'?

     

    And what is this 'Response' thing?!  :shrug:

     

     

    A html 'form' per say could (and often is) implemented as a 'View Helper'.

     

    Let's say I had a Log-In form with only an "Email" and a "Password" input field.

     

    How would what you are describing about be done?

     

     

    You may also have a 'Form' object which is specifically designed to validate user inputted data, before passing that data to a Controller for processing by a Model. This 'Form' object would not be considered a part of the 'View'

     

    Why not?

     

    If a Log-In Form could be part of the "View", then why not a Log-In object?

     

     

     

    TomTees

     

  13. Are you looking for a technical explanation, like "It sets users in the current object to the return value of $this->model->findAll()", or an explanation of what it actually achieves?  I can only help with the technical part unfortunately.

     

    What is "SET"?

     

    Are we talking about assigning a "constant" a value?

     

    Is it a variable?

     

    Follow my confusion?

     

     

    TomTees

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.