Jump to content

Easier way to shorten?


3raser

Recommended Posts

I want to ensure that the data received is set. Is there any other way I can shorten this condition?

 

I was thinking of a for loop, but I'm not sure that'd be considered more efficient.

 

if((!ctype_digit($_GET['forum']) && !ctype_digit($_POST['forum'])) || (!ctype_digit($_GET['id']) && !ctype_digit($_POST['id'])) || (!ctype_digit($_GET['type']) || !ctype_digit($_POST['type']))) $base->redirect('index.php');

Link to comment
https://forums.phpfreaks.com/topic/264273-easier-way-to-shorten/
Share on other sites

At only three fields it's not really worth trying to rework it into something that looks simpler but is actually more complicated. However you could use $_REQUEST as it contains both $_GET and $_POST values.

 

And there's a bug in there: pretty sure one of the four ||s should be a &&.

At only three fields it's not really worth trying to rework it into something that looks simpler but is actually more complicated. However you could use $_REQUEST as it contains both $_GET and $_POST values.

 

And there's a bug in there: pretty sure one of the four ||s should be a &&.

 

Ah, thank you. And yeah, thanks for pointing that out. Was a small bug.  ::)

Archived

This topic is now archived and is closed to further replies.

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