Jump to content

KrisNz

Members
  • Posts

    271
  • Joined

  • Last visited

Posts posted by KrisNz

  1. You aren't using strtotime correctly. If you want to add 28 days to a TIMESTAMP its

     

    $now = time();
    $tsTwentyEightDaysLater = strtotime("+28 day",$now); /*note that by default strtotime uses the current time() as the second argument. I'm just putting that in for clarity. */
    
    //In your case, you want to first convert your mm/dd/yyyy date to a TIMESTAMP
    
    $tsUserDate                      = strtotime($tse_start); //gives us a timestamp
    $tsTwentyEightDaysLater    = strtotime("+28 day",$tsUserDate); //gives us a timestamp
    $mdyTwentyEightDaysLater = date("m/d/Y",$tsTwentyEightDaysLater); //gives us an m/d/Y formatted date
    

  2. the beginning of the string should be {$row3['property_type']} - any hash key you access inside a string has to be inside {}. You can get around some of the messiness by using heredoc syntax (though the rule about {} I just mentioned still applies) or by breaking out of php like so

     

    <?php
    
    while($row3 = mysql_fetch_array($results3)) {
    ?>
    
    <tr>
        <td class="bodytext">
            <?php echo $row3['property_type'] ?>
            <input type="checkbox" name="<?php echo $row3['property_type'] ?>" value="<?php echo $row3['property_type'] ?>" />
        </td>
    </tr>
    <?php
    } //end while
    ?>

     

    I use a keyboard shortcut for <?php echo

     

  3. I don't really understand this..

    Note that globaling the $classes variable isn't an option since I'm going to be loading classes dynamically.

    But you might like to investigate the Registry pattern - this can be used to hold or retrieve a reference to your $classes hash.

  4. If I understand correctly, you've got a file that has a hash of class names and their associated file name? Doesn't this mean that every time you write a class you have to go and update that file? To me that somewhat defeats the purpose of having autoload. If you use a naming convention for your classes and their associated filenames you can avoid this altogether.

     

    If you camelcase your class names e.g

    <?php
    class ThisIsMyClass
    {
    //....
    }
    ?>
    

    Then name the file this_is_my_class.php

     

    You can convert the camelcase to the underscored version with this

    <?php
    function camelToUnderscore($s)
    {
       //http://www.regular-expressions.info/refadv.html
       //this translates to
       //look behind(to the right of)  the first character for any upper case
       //character and replace it with an underscore + the matched character
       return strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $s));
    }
    ?>
    

    That way you can convert $class_name to its matching file name without needing to keep a reference of it.

     

×
×
  • 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.