Jump to content
Larry Ullman's Book Forums

Tony

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Tony

  1. Thank you Larry, like I said, I am new to this stuff and the PHP manual is written for someone who knows this stuff and explains how to implement it in PHP, so for the most part I have trouble digesting it at best, and at worst I never really understand what it is saying. That's why I appreciate your books so much, you explain why and how things work with practical examples.

     

    By the way, any idea how/w the example code I started the topic works in calling the procedural function using object methods?

     

    Thanks,

     

    Tony

  2. Hi, still teaching myself, Larry's books are great. As I am not in the computer field, when I go to places like PHP.net for info I usually can't figure out what they are really trying to say to me. I hope that my question below is proper for this forum, if not please excuse my question and I will respectfully withdraw it.

     

    I bought the PHP 5 Advanced book really to learn OOP, something very new to me. I am able to work through Larry's examples an do eventually get things to work when I modify the examples, to be sure I understand how the coding works.

     

    I took Script 3.1 db_sessions.inc.php and decided to turn it into an object, originally I wasn't able to get it to work no matter what I tried. On PHP.net I saw:

     

    "When using objects as session save handlers, it is important to register the shutdown function with PHP to avoid unexpected side-effects from the way PHP internally destroys objects on shutdown and may prevent the
    write
    and
    close
    from being called. Typically you should register
    'session_write_close'
    using the
    function."

     

    I tried to figure out what this meant but wasn't able to make my script work, until I found an example on the Internet in a chat room that initiated the the function like this below, not by just sending the objects, but by passing each of them in a different array along with a '$this' as a separate array item:

     

    session_set_save_handler( array($this,'OpenSession'),
        array($this,'CloseSession'),
        array($this,'ReadSession'),
        array($this,'WriteSession'),
        array($this,'DestroySession'),
        array($this,'GarbageCollectionSession'));
    

     

     

    Then everything worked, "CloseSession, ReadSession, WriteSession, DestroySession and GarbageCollectionSession are all objects that do their respective tasks.

     

    Can someone tell me why passing them as arrays with item [0] = "$this", and then item [1] = "TheObject" works, and also what kind of parameter have I passes. I would have not guessed that I could pass an array to a function in that manner without first assigning it to a variable?

     

    I am using XAMPP, PHP 5.3.8 and am on a Windows 7 PC.

     

    Any insight would be appreciated.

     

    Tony

  3. Everyone, thank you very much, Larry I have just started getting into your PHP 5 Advanced: Visual QuickPro Guide, it's a little deep for me but it to is very clear. These discussion boards are very useful and everyone is very helpful. That's a huge help for someone like me who has come to web design and scripting a little later in life than I think most do.

     

    I am still at a loss to understand what "./" does, and why XAMPP requires that relative path to get into the root of a site from one level out as opposed to the standard "../" that I normally have to use to go back one folder. I stumbled upon that by making a type as I was wracking my brain to understand why my relative addressing wasn't working. On a live host "./" just doesn't work for me. I'm not trying to "re-kill" the horse, so to speak, but I think if I can understand the logic behind XAMPP's requirement for "./" as opposed to the standard "../" will help me understand what is really going on.

     

    Once again thank you for all the help.

     

    Tony

  4. Jonathon thank you for the idea, I'll try that and HartleySan thanks for the links, I haven't checked them out yet but I will later today.

     

    Thank you both for your replies.

     

    For what it's worth I feel better knowing it isn't just me and that there are some differences between live hosting and XAMPP.

     

    Jonathan, just as you showed I to had to use a "./" to go one level back and get into the includes files when using XAMPP when I though I would have had to use:

     

    <?php
    include("../includes/file.php");
    ?>

     

     

    Do either of you know of any other cases where you had to use

     

    <?php
    include("./folder/file.php");
    ?>

     

    to relatively address a file anywhere else other than in XAMPP?

     

     

    The part of my question that was a little confusing was that I have a file in the includes folder (header.php) that contains

    include("./includes/snippet.php)

     

    when I built the site using XAMPP I had to include the snippet.php file relative to the header location, like I showed it above. But when I tried it on a live host that didn't work and I had to include the snippet file relative to the file that the header was being included into:

     

    include("../../includes/snippet.php)

     

    I don't know if many people put an include("includes/something") into another includes file. I did it as a work around to add a block of code to an existing header without having to work in the header and possibly ruin it.

     

    One last question, when you go live with a project you have been working on, how do you handle changing the paths from the XAMPP version to the live host version? Do you have both versions in the code and have the code select which paths to use based on something like server information, or do you just hard code the changes to work on a host when you are ready to go live?

     

    Thanks in advance for all the help.

     

    Tony

  5. Hi all, I wasn't sure where to post this so I figured I would try here. I am a big fan of the PHP6 MySQL 5 Visual QuickPro Guide, I learned PHP and MySQL exclusive through it, and when I had questions the associated forum members were always very helpful, so I thought I would try posting the question here. If this posting is inappropriate I apologize.

     

    Having come to web design and programming later in life, some of the basics caused me real problems. For example, when I develop sites I use XAMPP, per the QuickPro Guide. In the beginning I had trouble understanding how it worked but with help initial from forum members and by trial and error I can get by now. The recent trouble I have had is with relative directory addressing. In the past I used absolute addresses and had no problems, but for the latest project I am working on I wanted to use only relative addresses to make the site more flexible and so I could use parts of it for future projects.

     

    Here's the problem. When in the root folder, when on a live Host can be referenced by: "/", but XAMPP seems to need "./", a "../" or a "/" both won't work. Also, when I include an includes file into another includes file (this was a work around for an additional requirement) when on XAMPP the relative path for the second includes was did not require changing folders. But when the site went live that wasn't the case. When on the live Host The second included file had to be relatively addressed as if it was being included from the file the first file was included in (sorry for the confusion here).

     

    Can anyone give me a link, or otherwise explain if XAMPP is different from live hosts? I have only used one hosting company so far and am wondering if their set up is unique and possibly not standard.

     

    Sorry for the long winded post, and thanks for any help in advance.

     

    Tony

×
×
  • Create New...