Skip to main content

PHP 8 New Concepts

 PHP 8 New Concepts

PHP 8 is a major update to the PHP programming language, which was released on November 26, 2020. It introduces several new features and improvements over the previous version, PHP 7. Here are some of the key new concepts introduced in PHP 8:

  1. Union Types: PHP 8 introduces union types, which allow for defining a variable or parameter that can accept multiple types. This allows for more flexibility in defining function signatures and can make it easier to write code that can handle different types of input.

  2. Named Arguments: PHP 8 introduces named arguments, which allow for passing arguments to a function by name, rather than position. This can make it easier to understand the purpose of each argument, and can make it easier to change the order of arguments.

  3. Attributes: PHP 8 introduces attributes, which are metadata that can be associated with classes, methods, properties, and other language constructs. They can be used to provide additional information about a construct, such as its purpose or how it should be handled by a specific tool or framework.

  4. Match Expressions: PHP 8 introduces match expressions, which are similar to switch statements but with improved type safety and error handling. They allow for easy pattern matching and can help make code more readable and maintainable.

  5. Null Coalescing Assignment Operator: PHP 8 introduces the null coalescing assignment operator (??=), which allows for assigning a value to a variable only if it is currently null. This can help reduce the amount of code needed to check for null values before assigning a value.

  6. JIT Compiler: PHP 8 introduces a Just-In-Time (JIT) compiler, which can improve the performance of PHP applications by dynamically compiling certain parts of the code at runtime. This can help reduce the overhead of interpreting PHP code and can lead to significant performance gains.

  7. Improved Type Safety: PHP 8 introduces several improvements to type safety, including stricter type checking, improved error handling, and more consistent type coercion. This can help reduce the number of bugs in PHP code and make it easier to catch and fix errors.

  8. Other improvements: PHP 8 also includes other improvements such as improved support for Unicode, improved support for 64-bit integers, and improved support for exceptions.

These are just some of the new concepts introduced in PHP 8. It is worth to check the official documentation to have a deeper understanding of the new features and how to use them effectively in your code

Comments

Popular posts from this blog

Run and compile sass scss file to css using node

  Today we learn how to use scss and generate css using node  or Run and compile sass scss file to css using node   So please follow simple  steps :-   Today we will create a project that can read scss file and generates css with it  Note: Make sure you have installed node in your system. If you want to help to install node js based on your system then check our other tutorial or check node js official website. Now create a blank folder and open  terminal(linux) or cmd(windows) and navigate to your current project folder by using cd command Now run below command npm init after enter it will ask you some package info that you can fill according to you or just keep enter until it finished. The above command will generate package.json file Now  we will install npm module that will convert our scss to css Run below command: npm install node-sass So we have installed node-sass package . Now open package.json file in your editor and add below code into it into

How to retrieve Facebook Likes, share , comment Counts

function facebook_count($url){     // Query in FQL     $fql  = "SELECT share_count, like_count, comment_count ";     $fql .= " FROM link_stat WHERE url = '$url'";     $fqlURL = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql);     // Facebook Response is in JSON     $response = file_get_contents($fqlURL);     return json_decode($response); } $fb = facebook_count('https://www.facebook.com/BahutHoGyiPadhai'); // facebook share count echo $fb[0]->share_count;  echo "like"; // facebook like count echo $fb[0]->like_count ; echo "comment"; // facebook comment count echo $fb[0]->comment_count;  ?>

jQuery Datatable add date range filter

jQuery Datatable add date range filter Datatable is most useful jQuery plugin that helps to make our html tables more powerful and give powers to user to filter , search, sort, pagination etc, But Data table provides a common filter only and yes we can customize and add filter for each column, but still sometimes we need an advance filter like show results only between a date range, So today we will learn how to create a minimum and maximum date range fields and show date picker on it, and user can fill dates by selecting dates and data table will auto filter records based on it. Keep follow below steps :- I am using Bootstrap if you want to use any other framework then you can use. Create a new index.php file  and paste below code in it, i have used all required CDN like bootstrap, datatable, datepicker etc. <!DOCTYPE html> <html> <head>     <title>Datatable Date Range Filter Example</title>     <link rel="stylesheet" href="https://maxcd