• Resolved bradaverhill

    (@bradaverhill)


    I am having a problem in displaying the results of the “calculation” as the php is printing the string and char count.

    I am a total noob at php, The first set of code works and does what it is to do. but it is printing out the number of characters in each of the text strings.

    I tested with some simple php and it does the echo as I would expect.

    I have struggled with this a good part of the weekend and have had no luck in resolving this, so any help will be greatly appreciated.

    
    // new date/time object
    $date = new DateTime('now');
    
    // set order time to a Saturday, 2 pm
    $date->modify('next mon 14:00');
    
    // orders are taken in till 15 minutes before 2pm
    // https://php.net/manual/de/datetime.formats.relative.php
    $order_till = new DateTime('front of 14');
    
    // preserve original date
    $date_min = clone $date;
    
    // use interval
    //$date_min->add(new DateInterval("P1D"));
    // orders after 1:45 pm are getting shipped the next day
    if($date > $order_till)
    {
        $date_min->modify('0 weekdays');
    }
    
    // if it's on a weekend then it gets shipped on monday
    if($date_min->format('N') >= 5){
        $date_min->modify('next monday');
    }
    
    // add delivery time
    $date_min->modify('1 weekdays');
    var_dump('Order Before',  $date->format('l jS \of F Y H:i:s'));
    var_dump("Delivery", $date_min->format('l jS \of F Y'));
    
    echo '<h2>PHP is Fun!</h2>';
    echo 'Hello world!<br>';
    echo 'Im about to learn PHP!<br>';
    echo 'Delivery ', 'string ', 'was ', 'Order Before ', 'with multiple parameters.';
    ?>
    
    
    
    The code prints the following:
    
    

    string(12) “Order Before” string(33) “Monday 11th of July 2022 14:00:00” string(8) “Delivery” string(25) “Tuesday 12th of July 2022”

    PHP is Fun!
    Hello world!
    Im about to learn PHP!
    Delivery string was Order Before with multiple parameters.`

    • This topic was modified 2 years, 8 months ago by bradaverhill.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Temyk

    (@webtemyk)

    Hello.

    Use
    echo "some text";

    Thread Starter bradaverhill

    (@bradaverhill)

    Hi

    I tried to use echo with

    
    var_dump('Order Before',  $date->format('l jS \of F Y H:i:s'));
    var_dump("Delivery", $date_min->format('l jS \of F Y'));
    

    but got errors. I really am a total noob with php. the two var_dump lines are producing basically the correct output.

    i tried

    echo “var_dump(‘Order Before’, $date->format(‘l jS \of F Y H:i:s’));’

    but got an error.

    Plugin Support Temyk

    (@webtemyk)

    Then you need to learn at least the basics of PHP first
    echo 'Order Before '.$date->format('l jS \of F Y H:i:s')

    Thread Starter bradaverhill

    (@bradaverhill)

    Thank you very much for your help. I really appreciate it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘String and Char count being displayed and I can’t fix’ is closed to new replies.