ms - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of ms.php
- <?php
- // Check if the user is using a mobile device
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false) {
- // Check if the user is connected to the internet using mobile data
- if (filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP) === false) {
- // Check if the user's mobile network supports the passing of the MSISDN in the HTTP headers
- if (array_key_exists('HTTP_X_MSISDN', $_SERVER)) {
- // Get the MSISDN
- $msisdn = $_SERVER['HTTP_X_MSISDN'];
- // Do something with the MSISDN
- echo "The user's MSISDN is: $msisdn";
- } else {
- echo "The user's mobile network does not support the passing of the MSISDN in the HTTP headers.";
- }
- } else {
- echo "The user is not connected to the internet using mobile data.";
- }
- } else {
- echo "The user is not using a mobile device.";
- }
- ?>