Skip to main content
codingCourses
  • HTML
  • CSS
  • JavaScript
  • PHP
  • PHP Tutorial
  • PHP Data Types
  • PHP Strings
  • PHP Regex
  • PHP Arrays
  • PHP URLs
  • Code Snippets
PHP
  • PHP Tutorial
  • echo vs. print
    Understanding echo and print Statement
  • include vs. require
    Differences and Usage
  • Superglobals
    Simple and Essential Usage Guide
  • Constants
    define() vs. const and Array Constants
  • isset() and empty()
    Concepts, Usage, and Key Differences
  • for Loop
    The Essential Basic Loop
  • while Loop
    A Loop That Runs While the Condition Is True
  • do…while Loop
    A Loop That Runs at Least Once
  • foreach Loop
    Iterating Over Arrays and Objects
PHP Data Types
  • Data Type Reference
  • NULL
    NULL Type and Value
  • gettype()
    Get the Data Type of a Variable as a String
  • is_int()
    Check if Integer
  • is_float()
    Check if Float
  • is_numeric()
    Check if Numeric
  • is_string()
    Check if String
  • is_array()
    Check if Array
  • is_bool()
    Check if Boolean
  • is_object()
    Check if Object
  • is_resource()
    Check if Resource
  • is_null()
    Check if NULL
PHP Strings
  • String Reference
  • strlen()
    Get String Length
  • mb_strlen()
    Multibyte-Safe Alternative to strlen()
  • trim()
    Trim Whitespace
  • strpos()
    Find First Substring Index
  • mb_strpos()
    Multibyte-Safe Alternative to strpos()
  • stripos()
    Find First Substring Index (Case-Insensitive)
  • mb_stripos()
    Multibyte-Safe Alternative to stripos()
  • str_contains()
    Check if a String Contains a Substring
  • substr()
    Slice Strings by Position and Length
  • mb_substr()
    Multibyte-Safe Alternative to substr()
  • ctype_digit()
    Check if Only Numeric Character(s)
  • explode()
    Convert a String to an Array
  • str_split()
    Split String by Length
  • mb_str_split()
    Multibyte-Safe Alternative to str_split()
  • str_replace()
    Replace Text in a String
PHP Regex
  • Regular Expressions Reference
  • preg_replace()
    Replace Text Using Regexes
  • preg_match()
    Check if a String Matches a Regex
  • preg_match_all()
    Find All Matches of a Regex
  • preg_split()
    Split String Using Regexes
PHP Arrays
  • Array Reference
  • array() and [ ]
    Array Creation and Syntax
  • count()
    Check Array Length
  • sizeof()
    Alias of count()
  • in_array()
    Check if a Value Exists in an Array
  • implode()
    Convert an Array to a String
  • join()
    Alias of implode()
  • array_map()
    Ideal for mapping array data to new values
  • array_filter()
    Filter Elements with a Callback
  • array_reduce()
    Reducing an Array to a Single Value
  • array_key_exists()
    Check if a Key Exists in an Array
  • array_keys()
    Get a List of Array Keys
  • array_values()
    Get a List of Array Values
  • array_search()
    Searching for a Value in an Array
  • array_unique()
    Remove Duplicate Values from an Array
  • array_diff()
    Finding Array Differences by Value
  • array_diff_assoc()
    Comparing Array Differences by Key–Value
  • array_intersect()
    Finding Common Values Between Arrays
  • array_intersect_assoc()
    Find Common Elements by Key-Value
  • array_slice()
    Slicing an Array
  • array_shift()
    Remove the First Element from an Array
  • array_merge()
    Merging Arrays
  • array_pop()
    Remove the Last Element from an Array
  • array_unshift()
    Add Elements to the Start of an Array
  • array_push()
    Add Elements to the End of an Array
  • array_reverse()
    Return Array Elements in Reverse Order
PHP URLs
  • PHP URL Reference
  • parse_url()
    Parsing URL Components
  • URL Encoding Functions
    Function Purpose & Features
  • urlencode()
    Encoding a URL Query Parameter Value
  • rawurlencode()
    Safely Encoding URI Components
  • http_build_query()
    Build Query Strings from Arrays or Objects
  • URL Decoding Functions
    Function Purpose & Features
  • urldecode()
    Decoding URLs Encoded with urlencode()
  • rawurldecode()
    Decoding URLs Encoded with rawurlencode()
  • parse_str()
    Parse URL Query Strings into Variables
PHP Code Snippets
  • Code Snippets
  • Detecting Client Browser Info
    $_SERVER['HTTP_USER_AGENT']
  • Detecting Mobile Devices
    Working with Functions for Mobile Detection
  • Distinguishing Between iOS and Android
    Methods to Check if Running on iOS or Android

PHP Code Snippets

PHP Next

Useful PHP code snippets for development and common programming tasks, including detecting mobile devices and distinguishing between iOS and Android in PHP.

PHP Code Snippets
Detecting Client Browser Info
$_SERVER['HTTP_USER_AGENT']
The $_SERVER['HTTP_USER_AGENT'] variable is used to detect the client's browser from the HTTP request.
Detecting Mobile Devices
Working with Functions for Mobile Detection
This guide covers PHP code for checking whether the current device is running on a mobile platform, such as a smartphone or tablet.
Distinguishing Between iOS and Android
Methods to Check if Running on iOS or Android
This guide covers PHP code to check whether the current mobile device is running on iOS or Android.
PHP Next

codingCourses offers coding tutorials made for everyone.
All materials and examples are continuously reviewed to prevent errors; however, complete accuracy cannot be guaranteed.
Therefore, please carefully test and review all materials and examples to ensure they are free of errors, bugs, or vulnerabilities before relying on them.
They are available under the Creative Commons Attribution 4.0 International

Copyright © codingCourses. All Rights Reserved.