Urmila Samariya has Published 135 Articles

Nullsafe Operator in PHP 8

Urmila Samariya

Urmila Samariya

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

1K+ Views

PHP 8 uses nullsafe operator instead of a null check condition. Using the nullsafe operator, we can use a chain of calls. While evaluating the elements, if one chain element fails, then the execution of the entire chain will abort and it evaluates to null.When the left-hand side operator evaluates ... Read More

Match Expression in PHP 8

Urmila Samariya

Urmila Samariya

Updated on 01-Apr-2021 06:32:54

766 Views

Match expression is a new feature that is added in PHP 8. It is very much similar to switch-case statements, but it provides more safe semantics.Match expression does not use the 'case and break' structure of switch-case statements. It supports joint conditions, and it returns a value rather than entering ... Read More

Union Type in PHP 8

Urmila Samariya

Urmila Samariya

Updated on 01-Apr-2021 06:26:20

834 Views

Using Union Type in PHP 8, we can use the values of two or more types, instead of using a single type. To specify multiple types, vertical line (|) is used to join them.Union type supports parameters, return types, and properties.Syntaxtype1|type2|……|type_nExample 1: Union TypeExample 2: PHP 8 Program using Union ... Read More

Attributes in PHP 8

Urmila Samariya

Urmila Samariya

Updated on 01-Apr-2021 06:24:08

3K+ Views

Attributes are kinds of classes that can be used to add metadata to other classes, functions, class methods, class properties, constants, and parameters. Attributes do nothing during runtime.Attributes have no impact on the code, but available for the reflection API. Attributes in PHP 8 allow other code to examine the ... Read More

Reading Attributes with Reflection API in PHP 8

Urmila Samariya

Urmila Samariya

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

656 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

317 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

458 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

630 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

14K+ 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

513 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

Advertisements