Welcome Guest, Not a member yet? Register   Sign In
How to understand if parameter is empty
#1

Hi. For example i have a delete method in users controller. I want to if there is no parameter i should redirect the user.

For example these codes are not working. I am waiting advices.

PHP Code:
public function delete($incomingId)
 
   {
 
       if (empty($incomingId)) {
 
           redirect(base_url());
 
       }
 
   
or

PHP Code:
public function delete($incomingId)
 
   {
 
       if (!$incomingId) {
 
           redirect(base_url());
 
       }
 
   
PHP Code:
public function delete($incomingId)
 
   {
 
       if (!isset($incomingId)) {
 
           redirect(base_url());
 
       }
 
   
Reply
#2

PHP Code:
public function delete($incomingId null)
{
 
   if (is_null($incomingId)) {
 
       redirect(base_url());
 
   }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(06-16-2019, 12:24 PM)InsiteFX Wrote:
PHP Code:
public function delete($incomingId null)
{
 
   if (is_null($incomingId)) {
 
       redirect(base_url());
 
   }


Thanks it worked  Big Grin Big Grin
Reply




Theme © iAndrew 2016 - Forum software by © MyBB