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.



Your result can be seen below.

Result of php executing





Full code of ms.php

  1. <?php
  2.  
  3. // Check if the user is using a mobile device
  4. if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false) {
  5.  
  6.     // Check if the user is connected to the internet using mobile data
  7.     if (filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP) === false) {
  8.  
  9.         // Check if the user's mobile network supports the passing of the MSISDN in the HTTP headers
  10.         if (array_key_exists('HTTP_X_MSISDN', $_SERVER)) {
  11.  
  12.             // Get the MSISDN
  13.             $msisdn = $_SERVER['HTTP_X_MSISDN'];
  14.  
  15.             // Do something with the MSISDN
  16.             echo "The user's MSISDN is: $msisdn";
  17.         } else {
  18.             echo "The user's mobile network does not support the passing of the MSISDN in the HTTP headers.";
  19.         }
  20.     } else {
  21.         echo "The user is not connected to the internet using mobile data.";
  22.     }
  23. } else {
  24.     echo "The user is not using a mobile device.";
  25. }
  26.  
  27. ?>
  28.  
File Description
  • ms
  • PHP Code
  • 06 May-2023
  • 937 Bytes
You can Share it: