Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    What is the different between return ($row) and return $row in php

    Back-End Development
    php backend
    2
    2
    486
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fahathmtm last edited by

      while ($stmt->fetch()) {
      $row[] = array('id'=>$id,'driver_id'=>$driver_id,'duty_date'=>$duty_date,'duty_timing_sec'=>$duty_timing_sec);
      }

      $stmt->close();
      
      if(!empty($row))
      {
      	return ($row);
      }
      else
      {
      	return "";
      }
      
      1 Reply Last reply Reply Quote 0
      • b6
        b6 last edited by b6

        There is no different, Usually brackets used to grouping the calculation and get final value..

        Instead of,

        $amount = $price - $discount;
        return $amount;
        

        You can use,

        return ($price - $discount);
        

        But in your case, $row is an Array. Array is a single element, So no need brackets..

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post

        0
        Online

        3.7k
        Users

        1.3k
        Topics

        5.3k
        Posts

        • Privacy
        • Terms & Conditions
        • Donate

        © Copyrights and All right reserved Lanka Developers Community

        Powered by Axis Technologies (PVT) Ltd

        Made with in Sri Lanka

        | |