Function __global->is_mobile

Definitions

sources/global3.php

  • Look at the user's browser, and decide if they are viewing on a mobile device or not.A mobile device can generally be considered a touchscreen device with a screen smaller than a desktop/laptop.There is no perfect delineation.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: bool

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$user_agent ?string No No Null N/A N/A The user agent (null: get from environment, current user's browser)
$include_tablets boolean No No False N/A N/A Whether to include tablets (which generally would be served the desktop version of a website)
$truth boolean No No False N/A N/A Whether to always tell the truth (even if the current page does not have mobile support)

Returns

  • Whether the user is using a mobile device
  • Type: boolean
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Look at the user's browser, and decide if they are viewing on a mobile device or not.A mobile device can generally be considered a touchscreen device with a screen smaller than a desktop/laptop.There is no perfect delineation.
 *
 * @param  ?string $user_agent The user agent (null: get from environment, current user's browser)
 * @param  boolean $include_tablets Whether to include tablets (which generally would be served the desktop version of a website)
 * @param  boolean $truth Whether to always tell the truth (even if the current page does not have mobile support)
 * @return boolean Whether the user is using a mobile device
 */

function is_mobile(?string $user_agent = null, bool $include_tablets = false, bool $truth = false) : bool