Replies: 6 comments
-
@luchaos I was taking a look at the new features of PHP 7 and noticed an interesting operator: Null coalescing operator. Am I wrong or we could make function seekGET( $key, $default = NULL )
{
return $_GET[ $key ] ?? $default;
}
function seekPOST( $key, $default = NULL )
{
return $_POST[ $key ] ?? $default;
}
function seekPOSTorGET( $key, $default = NULL, $type = NULL )
{
$retval = $_POST[ $key ] ?? $_GET[ $key ] ?? $default;
if( isset( $type ) )
settype( $retval, $type );
return $retval;
} |
Beta Was this translation helpful? Give feedback.
-
that does indeed work, very useful as it omits errors as well (like when the check in question is an undefined index of an array) |
Beta Was this translation helpful? Give feedback.
-
@luchaos this part of my code: if( isset( $type ) )
settype( $retval, $type ); brought me a question: is there a builtin way to check if an input is a valid type? Or would I need to hardcode the comparison with the known valid types? EDIT: trying to be more clear. I want to avoid situations like |
Beta Was this translation helpful? Give feedback.
-
@meleu with Laravel we will have a Validator at hand with extensive options (see https://laravel.com/docs/5.6/validation) |
Beta Was this translation helpful? Give feedback.
-
@luchaos can we generate API docs like this?: https://laravel.com/api/5.6/ is it enough to use that javadoc-style comments? this looks really cool and useful! 😍 |
Beta Was this translation helpful? Give feedback.
-
We definitely will have an API documentation, but not like Laravel's internal API as that's for the framework/library API docs which are base on docblocks. The API we're exposing is not for a library but for a web API. |
Beta Was this translation helpful? Give feedback.
-
This is not an issue nor a feature request!
Just a thread where we can share some tips and tricks about PHP and thoughts about some parts of RAWeb's code.
Beta Was this translation helpful? Give feedback.
All reactions