Urmila Samariya has Published 141 Articles

Reading Attributes with Reflection API in PHP 8

Urmila Samariya

Urmila Samariya

Updated on 01-Apr-2021 06:21:56

576 Views

In PHP 8, we use classes, properties, and class constants, methods, functions, parameters to access the attributes.In PHP 8, Reflection API delivers the getAttribute() method on every matching Reflection object.The getAttribute() method returns an array of ReflectionAttribute illustrations that can be asked for attribute name, arguments and to instantiate an ... Read More

Number comparisons in PHP 8

Urmila Samariya

Urmila Samariya

Updated on 01-Apr-2021 06:21:16

234 Views

When we compare a numeric in PHP 8, it will use number comparison. Else it will convert the number to a string and will use the string comparison.The string can be categorized in three ways −A string that contains only numeric. Example − 1234 or 1.24e1.A leading–numeric string − A ... Read More

Uniform variable syntax in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 07:13:50

321 Views

In the older versions of PHP, we faced an inconsistency problem. For example: ${$first [‘name’]}. This syntax may create confusion or we can say that the syntax is not consistent. To overcome the inconsistency problem, PHP 7 added the new syntax called “Uniform variable syntax”.The uniform variable syntax evaluates the ... Read More

Unicode codepoint escape syntax in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 07:11:29

441 Views

PHP 7 takes a Unicode codepoint in hexadecimal form as input and produces the outputs in UTF-8 character format within a double-quoted string. It could be any combination of hexadecimal digits, 2, 4, 6, and above. We can write Unicode characters by using a double-quoted or here docstring, without calling ... Read More

Display array structure and values in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 07:06:12

13K+ Views

An array in PHP is a type of data structure that can store multiple elements of similar data type under a single variable.To display array structure and values in PHP, we can use two functions. We can use var_dump() or print_r() to display the values of an array in human-readable ... Read More

Exceptions and Error in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 07:03:46

457 Views

In the earlier versions of PHP, we could handle only exceptions. It was not possible to handle errors. In the case of a Fatal Error, it used to halt the complete application or some part of the application. To overcome this problem, PHP 7 added the throwableinterface to handle both ... Read More

Preg_replace_callback_array() in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 06:29:55

212 Views

Preg_replace_callback_array() function in PHP 7 represents a regular expression and replaces the use of callbacks. This function returns a string or an array of strings to match a set of regular expressions and replaces them using a callback function.Syntaxpreg_replace_callback_array(patterns, input, limit, count)Parameter Values:pattern − It requires an associate array to ... Read More

Generator delegation in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 06:28:09

363 Views

The concept of generator is not new to PHP 7, because it was available in the earlier versions too. With generators, implementation becomes easy without the overhead of implementing a class that implements the iterator interface. With the help of a generator, we can write foreach code without using an ... Read More

Generator Return Expressions in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 06:18:57

287 Views

In the previous versions of PHP, generator functions were not able to return expressions, but from the PHP 5.5, generator return expression is added in the existing one. By using generator return expressions, it is easy to use the return statement within a generator and, it also returns the value ... Read More

Types of Group Use declarations in PHP 7

Urmila Samariya

Urmila Samariya

Updated on 13-Mar-2021 06:16:07

149 Views

PHP 7 uses three different types of Group Use declarations −Non-mixed-use declarationsMixed-use declarationsCompound use declarationsNon-mixed-use declarations:Non-mixed-use declaration means we do not use the classes, functions, and constructs in a single statement. Or, we can say that when we declare classes, functions, and constants separately using a use statement. It is ... Read More

Advertisements