I’m trying to reverse-engineer a wordpress plugin, and I’m having a hard time understanding another piece of code.
The plugin is : http://wordpress.org/extend/plugins/wordpress-social-login/
This time I have this following few lines:
$wslp = @ (int) $_REQUEST["wslp"];
if( $wslp < 1 || $wslp > 6 ){
$wslp = 1;
}
My concern is, what does $wslp equal to when the wslp parameter is not set ( == when the $_request is not set)
The next line gets a page by this number so it can’t be just empty or null…
@is used to suppress PHP warnings.When using
(int), anything that cannot be converted to an integer becomes0.So, when
$_REQUESTdoes not contain the keywslp,$_REQUEST["wslp"]returnsNULL(with an undefined offset warning) and(int) NULLyields0.Edit
A much better way to grab value from query string, convert it to desired type, validate it, and fallback default (e.g. when value is missing or invalid) is to use the PHP
filter_inputfunction: