Found 1060 Articles for PHP

PHP asinh() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:22:30

234 Views

Definition and UsageThe asinh() function calculates inverse of hyperbolic sine of given parameter. In other words, the return value of asinh() is hyperbolic sine of given parameter. A inverse hyperbolic sine function is defined asasinh(x) = log(x+sqrt(pow(x, 2)+1))This function returns a float value.Syntaxasinh( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value whose inverse hyperbolic sine is to be calculatedReturn ValuesPHP asinh() function returns inverse hyperbolic sine 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 asinh(pi/2) which we can verify using the definition −OutputThis will ... Read More

PHP asin() Function

Ranjit Kumar
Updated on 29-Jun-2020 08:20:15

245 Views

Definition and UsageThe asin() function returns the arc sine or sine inverse of arg in radians. asin() is the inverse function of sin(). Therefore if sin(x)=y, asin(y)=x.For example, sin(pi/2)=1 and asin(1)=1.57079633 rad which is equal to pi/2.This function returns a float value.Syntaxasin ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point number whose arc sine is to be calculated. Number should be withing -1 to 1Return ValuesPHP asin() function returns arc sine of given number. It is angle represented in radians.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates ... Read More

PHP acosh() Function

Malhar Lathkar
Updated on 11-Jun-2020 09:51:30

262 Views

Definition and UsageThe acosh() function returns the inverse hyperbolic cosine ratio of given angle in of given parameter. In other words, the return value of asinh() is hyperbolic sine of given parameter. A hyperbolic inverse hyperbolic cosine function is defined as −.acosh(x) = log(x+sqrt(pow(x, 2)-1))This function returns a float value.Syntaxacosh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value whose inverse hyperbolic cosine is to be calculatedReturn ValuesPHP acosh() function returns inverse hyperbolic cosine ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.ExampleFollowing example calculates acosh(pi/2) and returns ... Read More

PHP acos() Function

Malhar Lathkar
Updated on 11-Jun-2020 08:36:23

292 Views

Definition and UsageThe acos() function Returns the arc cosine or cos inverse of arg in radians. acos() is the inverse function of cos(). Therefore if cos(x)=y, acos(y)=x.For example, cos(pi/2)=0 and acos(0)=1.57079633 rad which is equal to pi/2.This function returns a float value.Syntaxacos ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point number whose arc cosine is to be calculated. Number should be withing -1 to 1Return ValuesPHP acos() function returns arc cosine of given number. It is angle represented in radians.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates ... Read More

PHP abs() Function

Malhar Lathkar
Updated on 11-Jun-2020 08:30:57

3K+ Views

Definition and UsageThe abs() function is an in-built function in PHP iterpreter. This function accepts any number as argument and returns a positive value, disregarding its sign. Absolute value of any number is always positive.This function always returns positive number.Syntaxabs( mixed $num)ParametersSr.NoParameter & Description1numThis parameter stores a value whose absolute value is to be obtained.Return ValuesPHP abs() function returns absolute value of num. If data type of num is float, return type is also float.For integer parameter, return type is integer.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example shows that ... Read More

Difference between bindParam and bindValue in PHP

Nitin Sharma
Updated on 09-Jun-2020 08:30:50

4K+ Views

Both bindParam and bindValue are the inbuilt functions of PHP which are used for accessing database records by mapping variable to the value in PHP data objects statement also known as PDOStatement which is nothing else but is an abstraction layer for database queries.Following are the important differences between ASP and ASP.NET.Sr. No.KeybindParam functionbindValue function1DefinitionbindParam is a PHP inbuilt function used to bind a parameter to the specified variable name in a sql statement for access the database record.bindValue, on the other hand, is again a PHP inbuilt function used to bind the value of parameter to the specified variable ... Read More

How to prevent multiple inserts when submitting a form in PHP?

AmitDiwan
Updated on 09-Apr-2020 13:40:58

2K+ Views

PHP session can be used to prevent multiple inserts when submitting a form. PHP session sets a session variable (say $_SESSION['posttimer']) that sets the current timestamp on POST. Before processing the form in PHP, the $_SESSION['posttimer'] variable is checked for its existence and checked for a specific timestamp difference (say 2 or 3 seconds). This way, those insertions that are actually duplicates can be identified and removed.Simple form −// form.html         The reference to ‘my_session_file.php’ in the above will have the below lines of code −Exampleif (isset($_POST) && !empty($_POST)) {    if (isset($_SESSION['posttimer'])) {     ... Read More

PHP Casting Variable as Object type in foreach Loop

AmitDiwan
Updated on 09-Apr-2020 11:44:45

977 Views

This depends on the IDE that is being used. For example, Netbeans and IntelliJ can enable the usage of @var in a comment −/* @var $variable ClassName */ $variable->This way, the IDE would know that the ‘$variable’ is a class of the ClassName after the hint ‘->’ is encountered.In addition, an @return annotation can be created with a method that specifies that the return type will be an array of ClassName objects. This data can be accessed using a foreach loop that fetches the values of the objects −function get_object_type() {    return $this->values; } foreach( $data_object-> values as $object_attribute ... Read More

Sort php multidimensional array by sub-value in PHP

AmitDiwan
Updated on 09-Apr-2020 11:43:24

365 Views

The ‘usort’ function can be used to sort multidimensional arrays in PHP. It sorts an array based on a user-defined criteria −Example Live DemoOutputThis will produce the following output −2 4 63 81An array with 4 elements is declared and this array is passed to the usort function, as well as calling the user-defined ‘my_sort’ function on the elements to make sure that the sorting takes place is ascending order.

In PHP, how can I add an object element to an array?

AmitDiwan
Updated on 09-Apr-2020 11:41:50

3K+ Views

The code is as follows −Example$object = new stdClass(); $object->name = "My name"; $myArray[] = $object;OutputThis will produce the following output −Suppose myArray already contains ‘a’ and ‘c’, the value of “My name” will be added to it. It becomes Array {    a:0, c:1, “My name”:2 }The object is created and then it is pushed to the end of the array (that was previously present).Alternative$myArray[] = (object) ['name' => 'My name'];

Advertisements