Php

Php

How to use PHP and MySql in Web Development
Step 1: If we need to interact with database the first step is to connect with database. Here is object oriented style to connect with database.
$conn = new mysqli("localhost", "my_user", "my_password", "db_name");
Step 2: After sucessfly established connection with database we can perform CURD operation on database. Here are the function that are commonly
used to perform CURD :
Performs a query on the database
$result = $conn->query($sql_query)
Determine number of rows result set

read moreComment count(0}

The traits is very important concept that help the developer to implement the reuse and optimization of the code . Before giving the exact defination of trais let me share advantage traits

read moreComment count(0}

The interface, Abstract and inheritance are the very important concept of oops that will help to design the application perfectly. First let discss the difference between abstract class and interface then I will explain how to implemennt.

read moreComment count(0}

Namespaces : The namespaces is basically the name of folder/directory[physical or virtual] in which you put all code that belong to specific group. For example you are wrting code for image gallary then it is better to put all code in one folder with name "image_gallery" so that when you create other image gallery then you can simply put in other folder so but you use same class name and file name.The other benefit is that if your code integrated with other code then it do not create any problem.

read moreComment count(0}

PHP has an exception model similar to that of other programming languages but not as much powerful as other language like java. In Java if your code have possiblity for exception then it should be in exception block like connect to database othewise you can't compile your code . But in PHP you can write code without handling the exception even if your code can generate exception. Let me expain the basic structure of exception before going to explain this topic with code .

read moreComment count(0}

The oops refer to object oriented programming structure and it is technique to provide solution to business. Let me explain this topics with the help of pratical examle.

Requiremnts : Supose I have client  runing companey with name 'ABC Pvt Ltd' and have 50 employees, He want show the list of the employees on webpage. [Note : I have not implemented database in solution and just explained oops conept]

When I received the requirements then I analysed the requirements and design these requirements into oops conept

read moreComment count(0}

1) Performance

The PHP 7 uses a brand new model engine called PHP-NG or Next generation. This engine improve the performance double that is if you run same application in PHP 7 then it approximately decrease 50% response time for the application

2) Spaceship operator

The PHP 7 introduce new operator called spaceship operator(<=>) and it used in sorting and comparison

 

// Integers

echo 1 <=> 1; // 0

echo 1 <=> 2; // -1

echo 2 <=> 1; // 1

// Strings

read moreComment count(0}