Malhar Lathkar has Published 155 Articles

PHP Nested Exception

Malhar Lathkar

Malhar Lathkar

Updated on 18-Sep-2020 09:04:43

474 Views

IntroductionBlocks of try - catch can be nested upto any desired levels. Exceptions will be handled in reverse order of appearance i.e. innermost exception processing is done first.ExampleIn following example, inner try block checks if either of two varibles are non-numeric, nd if so, throws a user defined exception. Outer ... Read More

PHP Exception Handling with Multiple catch blocks

Malhar Lathkar

Malhar Lathkar

Updated on 18-Sep-2020 09:00:52

1K+ Views

IntroductionPHP allows a series of catch blocks following a try block to handle different exception cases. Various catch blocks may be employed to handle predefined exceptions and errors as well as user defined exceptions.ExampleFollowing example uses catch blocks to process DivisioByZeroError, TypeError, ArgumentCountError and InvalidArgumentException conditions. There is also a ... Read More

PHP Errors in PHP7

Malhar Lathkar

Malhar Lathkar

Updated on 18-Sep-2020 08:57:16

274 Views

IntroductionPrior to version 7, PHP parser used to report errors in response to various conditions. Each error used to be of a certain predefined type. PHP7 has changed the mechanism of error reporting. Instead of traditional error reporting, most errors are now reported by throwing error exceptions.If error exceptions go ... Read More

PHP Interaction between finally and return

Malhar Lathkar

Malhar Lathkar

Updated on 18-Sep-2020 08:47:10

1K+ Views

IntroductionThere is a peculiar behaviour of finally block when either try block or catch block (or both) contain a return statement. Normally return statement causes control of program go back to calling position. However, in case of a function with try /catch block with return, statements in finally block are ... Read More

PHP Exception Handling with finally

Malhar Lathkar

Malhar Lathkar

Updated on 18-Sep-2020 08:45:23

378 Views

IntroductionCode in finally block will always get executed whether there is an exception in ry block or not. This block appears either after catch block or instead of catch block.catch and finally blockIn following example, both catch and finally blocks are given. If execption occurs in try block, code in ... Read More

PHP Extending Exceptions

Malhar Lathkar

Malhar Lathkar

Updated on 18-Sep-2020 08:42:05

710 Views

IntroductionException class implements Throwable interface and is base class for all Exception classes, predefined exceptions as well as user defined exceptions. The Exception class defines some final (non-overridable) methods to implement those from Throwable interface, and __tostring() method that can be overridden to return a string representation of Exception object.final public function ... Read More

PHP rand() Function

Malhar Lathkar

Malhar Lathkar

Updated on 30-Jun-2020 08:29:10

228 Views

Definition and UsageThe rand() function returns an integer using pseudo random genaration technique. default range is between 0 and platform specific getrandmax(). On 64 bit Windows OS, it is 2147483647. The rand() function can be called without arguments (in which case the default range will be used) or by specifying ... Read More

PHP Predefined Mathematical Constants

Malhar Lathkar

Malhar Lathkar

Updated on 30-Jun-2020 07:36:18

109 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 NumberINFINFInfinityRead More

PHP tanh() Function

Malhar Lathkar

Malhar Lathkar

Updated on 30-Jun-2020 07:34:05

81 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 ... Read More

PHP tan() Function

Malhar Lathkar

Malhar Lathkar

Updated on 30-Jun-2020 07:31:07

100 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 ... Read More

Advertisements