Categories
PHP Code Snippets

PHP get class name without namespace

Below is the simple function to get class name without namesapce.

Categories
PHP Code Snippets

PHP – How To Check Number Is Odd Or Even

Here is simple PHP code snippet to check if a given number is odd or even. Check Number Is Odd Or Even How to use checkEven

Categories
PHP Code Snippets

Assign PHP value to JS

Categories
PHP Code Snippets

Check AJAX Request using PHP

Categories
PHP Code Snippets

PHP get function arguments as array?

func_get_args() returns an array with all arguments of the current function. PHP5.6 – splat operator Arrays and Traversable objects can be unpacked into argument lists when calling functions by using the … operator. This is also known as the splat operator in other languages.

Categories
PHP Code Snippets

How to change array keys from uppercase to lowercase?

The array_change_key_case() function changes all keys in an array to lowercase or uppercase. Syntax: This function takes array as a first parameter, It will return FALSE if given input is not an array. Second parameter is optional,you can pass either CASE_LOWER or CASE_UPPER and default value is “CASE_LOWER”. This function is supported from PHP 4.2 […]

Categories
PHP Code Snippets

Convert Comma Separated String into Array

Categories
PHP Code Snippets

PHP – Convert HEX to RGB

Below function takes hex code (e.g. #eeeeee), returns array of RGB values.

Categories
PHP Code Snippets

PHP – Cache Google Web Fonts using Api

Categories
PHP Code Snippets

Devicecloud digi – API Authentication Example using PHP

Categories
PHP Code Snippets

See if Value Exists in PHP Array

in_array() is the function to Check if a value exists in an array using PHP. Here is an example of how it is used: –

Categories
PHP Code Snippets

Check if two arrays are equal

Categories
PHP Code Snippets

How to read a file line by line in php

You can use the fgets() function with combination of fopne() funciton to read the file line by line. Using PHP5 spl iterators, object oriented style.

Categories
PHP Code Snippets

Better way to check variable for null or empty string?

Here is the simple PHP function for testing given data is null or empty string.

Categories
PHP Code Snippets

How to detect robots and spiders with PHP?

Here is the simple function for detecting spiders and robots. It will return true or false.