Mofizul

Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • Mofizul
    Keymaster

    If you are running the project from your Cpanel trying to use port 465 as a priority among other ports provide by Mailtrap, while running locally use 2525.

    in reply to: How to I can get the exact domain name with PHP #1464
    Mofizul
    Keymaster

    PHP

    
    if (!function_exists('site_url')) {
        function site_url()
        {
            $currentPath = $_SERVER['PHP_SELF']; 
            $pathInfo = pathinfo($currentPath);
            $hostName = $_SERVER['HTTP_HOST'];
            //$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"], 0, 5)) == 'https' ? 'https' : 'http';
            //echo $protocol . '://' . $hostName . $pathInfo['dirname'] . "";
            echo 'https://' . $hostName . $pathInfo['dirname'] . "";
        }
    }
    

    And use this like: <a href="<?php site_url(); ?>">Home</a>

    in reply to: Time format for Laravel 6 in view #1417
    Mofizul
    Keymaster

    {{ date('d-m-Y', strtotime($post->created_at)) }}

    in reply to: How to put 0 before single number in PHP #1402
    Mofizul
    Keymaster

    I have used the code: <?= str_pad($i, 2, 0, STR_PAD_LEFT) ?>

    Here is the explanation of the code: str_pad(($input, $pad_length, $pad_string = " ", $pad_type = STR_PAD_RIGHT))

    in reply to: How to count reading time in PHP #1398
    Mofizul
    Keymaster

    Suppose $post[‘description’] containing the description or text. Then you can write the code like:

    ``

    Now <?= $est ?>. Done

    in reply to: How to apply limit into foreach loop in PHP #1395
    Mofizul
    Keymaster

    Write your code like

    foreach (array_slice($posts, 0, 4) as $post){
    echo $post['title'];
    }
Viewing 6 posts - 1 through 6 (of 6 total)