note 126679 added to language.variables.external
| From: | krafttoast at fstph dot at | Date: | Mon, 13 Dec 2021 09:44:01 +0000 |
| Subject: | note 126679 added to language.variables.external | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217361@lists.php.net to get a copy of this message | ||
Interesting behavior I found while playing with $_GET
Using $_GET gives a string , if this string contains an integer, you can still work with it as if it
was an integer ( e.g. do addition,multiplication etc).
As far as i have tested this behavior it will only work with integer inputs.
Here is my example code:
<?php
/*
gets Variables through $_GET and does some arithmetic with them
*/
$a = $_GET['var1'];
$b = $_GET['var2'];
$c = $a*$b;
$d = $a+$b;
$e = sqrt(($a*$a)+($b*$b));
echo ('the multiplication is: ' . $c);
echo "<br>";
echo ('the addition is: ' . $d);
echo "<br>";
echo ('the pythagorean is :' . $e);
echo "<br>";
echo (var_dump($a)); //type of variable is string
echo "<br>";
echo (var_dump($b));//type of variable is string
?>
/index.php?var1=123&var2=123
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 81.223.67.62)
----
Manual Page -- https://php.net/manual/en/language.variables.external.php
Edit -- https://main.php.net/note/edit/126679
Del: integrated -- https://main.php.net/note/delete/126679/integrated
Del: useless -- https://main.php.net/note/delete/126679/useless
Del: bad code -- https://main.php.net/note/delete/126679/bad+code
Del: spam -- https://main.php.net/note/delete/126679/spam
Del: non-english -- https://main.php.net/note/delete/126679/non-english
Del: in docs -- https://main.php.net/note/delete/126679/in+docs
Del: other reasons-- https://main.php.net/note/delete/126679
Reject -- https://main.php.net/note/reject/126679
Search -- https://main.php.net/manage/user-notes.php