
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1060 Articles for PHP

767 Views
To check if a string contains a specific substring, the ‘strlen’ and ‘strpos’ functions can be used. The ‘strlen’ gives the entire length of the string. The function ‘strpos’ finds the position wherein the substring occurs first in the string.Example Live DemoOutputThe substring is present within the string.Two strings are defined and the position of the second string in the first string is checked with the help of the ‘strpos’ function and compared with the length of the first string. Relevant message is displayed on the console.

412 Views
The ‘^’ is a bitwise operator in PHP, i.e XOR (exclusive OR) bitwise operator, that is used to display the ASCII values of variables in question. For example − For evert bit in the value, the ^ operator checks if that bit is the same in the other value too. If the values are same, 0 is produced as an output, otherwise 1 is shown as output. Below is an example illustrating the same −Example Live DemoOutputb aDifferent variables are assigned character values and the ‘^’ operator is used to perform XOR on the two variables. Relevant output is displayed on the console.

1K+ Views
The basic idea behind late static bindings is that the concept of inheritance and the concept of ‘self’ keyword don’t follow the same rules. For example, a method ‘fun’ in parent class called in the child class won’t make ‘self’ refer to the child (as expected).The concept of late static bindings brings in a new keyword ‘static’, which when used, binds the function to the runtime class, or the class where the function was first used. In addition to this, any static function or variable is usually executed during runtime and not during compile time. Hence, if a value needs ... Read More

840 Views
Instead of copying the data from one variable to another one, the changes made to an array or object can be made to another using the ‘=&’ operator. This is known as the ‘assignment by reference’ method, which means both the values or objects will point to the same data, and no copies of the data are made. This way, data redundancy is avoided.Example Live DemoOutputThe value is : 89Inside the tags, two values are declared wherein the second value is the assignment by reference of the first value. Next, the value of the first variable is changed and the ... Read More

158 Views
It is an inbuilt function that compares the keys of one or more arrays, and returns their difference.Syntax of the array_diff_key functionarray array_diff_key($array1, $array2, ..)The function can take two or more array names as parameters, and compares the first array with the remaining arrays.Example Live DemoOutputArray ( [91] => Micheal )Inside the tags, three arrays are declared with certain values in them. They are printed by calling the ‘array_diff_assoc’ function by passing all the three arrays to it as parameters. The resultant value is the different between the first array, and second array as well as the difference ... Read More

192 Views
Definition and UsageConstantValueDescriptionM_PI3.14159265358979323846PiM_E2.7182818284590452354Euler Number eM_LOG2E1.4426950408889634074log2 eM_LOG10E0.43429448190325182765log10 eM_LN20.69314718055994530942loge 2M_LN102.30258509299404568402loge10M_PI_21.57079632679489661923pi/2M_PI_40.78539816339744830962pi/4M_1_PI0.318309886183790671541/piM_2_PI0.636619772367581343082/piM_SQRTPI1.77245385090551602729sqrt(pi)M_2_SQRTPI1.128379167095512573902/sqrt(pi)M_SQRT21.41421356237309504880sqrt(2)M_SQRT31.73205080756887729352sqrt(3)M_SQRT1_20.707106781186547524401/sqrt(2)M_LNPI1.14472988584940017414loge(pi)M_EULER0.57721566490153286061Euler constantPHP_ROUND_HALF_UP1Round halves upPHP_ROUND_HALF_DOWN2Round halves downPHP_ROUND_HALF_EVEN3Round halves to even numbersPHP_ROUND_HALF_ODD4Round halves to odd numbersNANNANNot A NumberINFINFInfinity

147 Views
Definition and UsageThe tanh() function returns the hyperbolic tangent ratio of given angle in radians. In trigonometry, hyperbolic tangent ratio is defined as.tanh(x) = sinh()/tanh()This function returns a float value .Syntaxtanh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP tanh() function returns hyperbolic tangent ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates tanh(pi/2) and returns 2.5091784786581 which is also the result of formula (ex + e-x))/2 −OutputThis will produce following result −tanh(pi) = 0.91715233566727 using formula = 0.91715233566727Example Live DemoFollowing example uses deg2rad() ... Read More

161 Views
Definition and UsageThe tan() function returns the tangent ratio of given angle in radians. In trigonometry, tangent of an angle is defined as ratio of lengths of opposite side and adjacent side.tan(x) = opposite/adjacenttangent of an angle is also defined as ratio of its sine and cosinetan(x) = sin(x)/cos(x)If x=45 degree, tan(x) = 1 as in a right angled traingle, opposite and adjacent sides are qual.This function returns a float value.Syntaxtan ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP tan() function returns tangent ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP ... Read More

338 Views
Definition and UsageThe srand() function is used to seed the random number generaror. Seeding initializes the random number generator. Most random number generators need initial seeding. In PHP, use of srand() function is optional as it is done automatically.This function doen't have any return value.Syntaxsrand ([ int $seed ] ) : voidParametersSr.NoParameter & Description1seedan integer to be used as seed. If not given, a random number is givenReturn ValuesThis function doesn't return any value.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoThis example the random number generator is first initialized before employing ... Read More

2K+ Views
Definition and UsageThe sqrt() function returns square root of a positive float number. Since square root for negative number is not defined, it returns NAN. This is one of the most commonly used functions.This function always returns a floating point number.Syntaxsqrt ( float $arg ) : floatParametersSr.NoParameter & Description1arga number whose square root is to be obtainedReturn ValuesPHP sqrt() function returns square root of the given arg number. For negative number, the function returns NAN.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculate square root of 100−OutputThis will produce following ... Read More