Trending November 2023 # Complete Guide On Php Compiler With Zend Engine # Suggested December 2023 # Top 13 Popular

You are reading the article Complete Guide On Php Compiler With Zend Engine updated in November 2023 on the website Minhminhbmm.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested December 2023 Complete Guide On Php Compiler With Zend Engine

Introduction to PHP Compilers

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

What is PHP Compiler?

It is a special kind of program that turns the PHP statements into the machine level language so that it could be understood by the system’s processor. The processor of any system understands only binary code, which means the compiler converts the high level language into the binary form so that it could be understood and processed by the processor. Any program is meaningless without a compiler. All of the IDEs that provides a complete platform to edit and run the program is comprised of the compiler that compiles the program written in it to the machine level language. In actual terms, the compiler is nothing but just a program that assists in turning anything written using the statements into the binary form.

The role of compiler is not just to turn the code into the machine level language but also to make sure that the statement written in the program are error-free. When it comes to error checking, the compiler ensures that the program is conforming to the syntax and have used the predefined keywords appropriately. When the compiler finds the error, it lets the developer know about it by providing the brief details about the error and such errors are known as compile time error. In the error, it shows the line number in which the issue is occuring together with the kind of error. The error has to be rectified in order to let the compiler turns the code into the binary code that could be understood by the processor.

Zend Engine PHP compiler

The working of the Zend engine is very simple and has been defined below using the diagram. In normal terms, the PHP code is turned into the machine level language which is then processed by the processor. But when working with the Zend compiler, the PHP script is turned into the Zend Opcodes. The opcodes are then leveraged while the generation of the HTML page that is served to the client eventually. It works in a simple manner and provides additional features as compared to the normal compiler. The Zend Engine also offers the runtime engine that lets the user work with the program. Though the Zend engine provides the platform to compile, it has to load the PHP script into the memory before it could initiate the entire compiling process.

The compiler that we used in our local servers comes inbuilt in that. They just compile the code and let the processor handle the compiled file in order to render the application. All the programming languages have their own compiler that can understand the code written on that particular programming language. The time taken by the compilers to compile the program file depends on its size. If it’s a large file or the line of code are much more in that case the compiler will take more time comparatively and vice versa.

Conclusion

The PHP compiler is a program that set of statements written in PHP to compile. It is considered very essential to work with any of the programming language as without compiler the codes barely make sense to the system. It is helpful in terms of converting the codes to the binary data that the processor leverages to render the application or to bring the functionality to the application.

Recommended Articles

This is a guide to PHP Compiler. Here we discuss the introduction, what is PHP Compiler along with the working of Zend Engine in detail. You may also look at the following articles to learn more –

You're reading Complete Guide On Php Compiler With Zend Engine

Complete Guide On Personal Finance

Personal finance refers to managing the way money is earned, the quantum of earned money to be spent & the quantum of money to be saved (i.e., managing the financial activities of a person) as per the choice & preference of the person considering the budgets, risk appetite, mortgage rates and planning for a future financial goal.

Start Your Free Investment Banking Course

Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & others

Explanation

Personal finance means finance for a person. The individual earns money either through business or a job. He wants to invest to cover his daily expenses and achieve his long-term financial goals.

Long-term financial goals may include marriage expenses for children, educational expenses for children, retirement funds, dream projects, buying a house, high net worth, etc. The goals can differ according to each personal preference.

He needs to have the guidance of some financial expert to cover his financial needs & goals appropriately.

Personal Finance Planning Process

The planning process of personal finance goes like this:

The individual first needs to assess where he stands today, i.e., understanding his finances. He needs to prepare his current sources of finances & his current estimated liabilities, if any.

If a person has substantial financial obligations, he should focus first on paying the financial obligations first. Only after then should he strive for savings & retirement goals.

Assuming that the individual has no obligation presently or has managed to pay his obligations, he needs to define a financial goal for the future.

He then needs to choose the alternatives available for investment purposes.

As per the plan, he must allocate his funds to the respective areas for each frequency selected above.

In case of a change in the investment environment, he must churn his portfolio accordingly.

Examples of Personal Finance (With Excel Template)

Let’s take an example to understand the calculation of personal finance in a better manner.

You can download this Personal Finance Excel Template here – Personal Finance Excel Template

A person does a job at a consultancy firm in the US. His monthly salary is $ 6500 as of now & the increment is due on July 1, 2023, with a bonus of one month’s pay in Oct 2023. Thus, after collecting all information, we have prepared a monthly budget for his revenues, expenses, savings, etc. (all amounts in US $)

Particulars

Jan-20

Feb-20

Mar-20

Apr-20

May-20

Jun-20

Jul-20

Aug-20

Sep-20

Oct-20

Nov-20

Dec-20

Revenues

Salary 6,500 6,500  6,500  6,500  6,500  6,500  7,800  7,800  7,800  7,800  7,800  7,800

Expected Bonus  –  –  –  5,000  –  –  –  –  –  7,800  –  –

Other Income  – 500  – 500 500  1,000  –  –  –  – 500  –

Total Income 6,500 7,000  6,500 12,000 7,000 7,500 7,800 7,800 7,800 15,600 8,300 7,800

Expenses

Rent 1,700 1,700  1,700  1,700  1,700  1,700  1,700  1,700  1,700  1,700  1,700  1,700

Food and Groceries 800 800 800 800 800 800 800 800 800 800 800 800

Entertainment 400 400 400 400 400 400 400 400 400 400 400 400

Childcare 1,000 1,000  1,000  1,000  1,000  1,000  1,000  1,000  1,000  1,000  1,000  1,000

Personal Clothing  –  – 500  –  – 500  –  –  1,000  –  –  1,500

Other Expenses 200 1,000 800 700 500  1,000  1,000  1,000  1,000  1,000  1,000  1,000

Total Expenses 4,100 4,900  5,200 4,600 4,400 5,400 4,900 4,900 5,900 4,900 4,900 6,400

Surplus (Deficit) 2,400 2,100  1,300 7,400 2,600 2,100 2,900 2,900 1,900 10,700 3,400 1,400

Cumulative Savings 2,400 4,500  5,800 13,200 15,800 17,900 20,800 23,700 25,600 36,300 39,700 41,100

Further, the funds are to be allocated as follows:

Emergency Fund 650 650 650 650 650 650 780 780 780 780 780 780

Savings Account 480 420 260  1,480 520 420 580 580 380  2,140 680 280

Investments 1,270 1,030 390  5,270  1,430  1,030  1,540  1,540 740  7,780  1,940 340

Total Allocation of monthly surplus 2,400 2,100  1,300 7,400 2,600 2,100 2,900 2,900 1,900 10,700 3,400 1,400

Explanation

We have assumed 10% of our salary as an emergency fund every month. 20% of the surplus amount as a savings account deposit every month. Each month, the surplus balance is transferred to the investment account for various investments.

As you observe at the end of the year, the total is as follows:

Emergency fund     8,580

Savings Account     8,220

Investments   24,300

Total   41,100

Thus, the person is financially independent at the end of the year due to prudent expenses & rational investments.

Types of Personal Finance

An essential savings account is treated as a type of personal finance medium. You can do so whenever you wish to withdraw specific amounts.

Choosing the appropriate stock from a list of stocks is necessary to increase return on investment. This is also terms as a means of personal finance.

If an individual wants to excel in human capital, he can avail of mortgages or loans to take up an educational loan (such as a loan for CFA).

Mortgages or loans may also be taken for leverage purposes to acquire a new asset.

Need for Personal Finance Principles of Personal Finance

Some of the basic principles of personal finance are as follows:

The most crucial focus in personal finance is savings. The more you save, the more funds you have for disposal. Savings gives you an ultimate level of confidence in routine business dealings.

Personal finance works best only after we have set the priorities for the spending pattern since resources are limited.

Save yourself from making unrequired or luxurious spending (such as buying an expensive car, watch, etc.). That means there is no space for “show-offs” in personal finance.

Investments should be made so that there are passive sources of income even if you haven’t worked to date.

Gaining after every experience is very important in this field. Financial education is necessary to excel in the field of personal finance.

Areas of Personal Finance

Let’s discuss each area of personal finance in a little more detailed manner:

Revenue: This is the start of personal finance. Unless you have something, how can you invest it? To generate revenue, a person does business or provides a reputed service. This business helps him get earned. The most common sources of revenue include salary for employment, bonus, dividend income, pension income, interest income, etc.

Expenses: Every revenue has a counterparty expense. Thus, you need to prioritize the expenses. First & foremost, the operating expenses are to be settled so that these expenses do not lag in the future. The ordinary expenses incurred by any individual are rental expenses, EMIs, welfare expenses, personal expenses, travel expenses, entertainment, taxes, etc. However, one may choose to pay the expenses through a credit card & take the benefit of an interest-free credit period.

Savings: All revenues less all expenses equals savings. This is the net amount retained at your disposal. This amount is compared to the revenue & one can understand the savings ratio to revenue. Savings can be reflected through the retention of physical cash, the amount in a savings bank account, investment in money market instruments, or other very liquid instruments. You should never invest 10% of your savings. It is always suggested to keep an emergency fund ready in an uncertain situation.

Investments: The amount allocated from savings is transferred to investments. By this, we mean purchasing certain assets that will generate revenue. Investment carries a risk. Every risk has an inevitable return. Risk & return go hand in hand. Investment can be made in stocks, equities, real estate, mutual funds, etc. Investment is to be made as per the risk appetite of the individual. Thus, this is the most critical area in personal finance.

Insurance: Insurance means financial protection in case of an unforeseen situation. For this, a certain amount is paid frequently. Some famous insurances are life, health, and stock insurance. Some insurers also provide the benefit of savings through the premium amount.

Why is Personal Finance Importance?

Finance, i.e., money, is the ultimate goal for every business person. Accumulation of money is given much more important than earning money. Personal finance comes into play as to how to manage this accumulated money. Investment ideas & other investment vehicles are necessary to channel this money source. Thus, personal finance is essential for any individual who wishes to earn more with time.

Benefits

Some of the benefits are:

You know precisely the quantum of money you have retained. Thus, there is no need to look for other sources of finance.

Leverage is a doubles-sized sword. One who does not know how to handle this sword should ideally invest the money in business from personal finances & not from loans.

Since you had invested the entire amount in the business, you retained 100% ownership. Thus, your business is debt-free & runs entirely on the business of the capacities inbuilt into the company.

You are not answerable to any outsider for finances.

If you have invested the entire amount in the business, you may not have the emergency funds for your family’s needs in case of any emergency.

Your expenses are reduced & you will think about spending less as always.

Non-availability of the source of finance in case any extra funds are required since no credit image is created.

By chance, the business is a loss-making venture; you lose your money.

Conclusion Recommended Articles

Complete Guide On Docker Workdir

Introduction to Docker WORKDIR

Docker WORKDIR is a Dockerfile instruction that is used to set the working directory for any of the instructions like RUN, CMD, ENTRYPOINT, COPY and ADD, which means any command mentioned after these instructions will be executed in the working directory that is specified using WORKDIR instruction in the Dockerfile. It also sets the working directory of a Docker container, which means if we have specified any path using WORKDIR and when we connect the container using the ‘exec’ command, then it will directory land us to that directory. Docker daemon creates the folder if the specified directory does not exist.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax:

Directory_Path: We can provide an absolute path at the top; else, it will be created under the ‘/.’

Directory_Name: We can only provide the directory name as well.

How does WORKDIR Command work in Docker?

As seen, WORKDIR instruction is used to set the current working directory for the container so that subsequent instructions like RUN, CMD, ENTRYPOINT, etc., do not require to give the absolute path as it executes the command in the working directory that WORKDIR specifies. Therefore, we can use WORKDIR instruction multiple times, and if the relative path is provided in the further WORKDIR instruction, then it will be related to the previous WORKDIR instruction.

RUN pwd

If we create an image using the above Dockerfile and run it, then it will output the present working directory, i.e.,/home/my_home/Desktop.

We can also use the environment variables in WORKDIR instruction if any environment variable is defined in the Dockerfile previously using ENV instruction. However, we can only use the environment variable defined explicitly in the Dockerfile, which means the environment variable we want to use in the WORKDIR instruction must be set in the same Dockerfile prior to use it.

Examples of Docker WORKDIR

Given below are the examples of Docker WORKDIR:

Example #1

Create a Docker image with single WORKDIR instruction.

a. Create a Dockerfile and populate it with the below data:

$vi Dockerfile

ENTRYPOINT [“nginx”, “-g”, “daemon off;”]

b. Create an chúng tôi file and populate it with some HTML code as shown below:

$vi index.html

c. Build a new image using Dockerfile mentioned in step 1:

docker build -t my-nginx .

Output:

Explanation:

In the above snapshot, the below steps are taken by the Docker daemon.

Step 1/5: Docker daemon creates a container using the ‘Ubuntu’ docker image in the first step.

Step 2/5: The second step changes the directory to ‘/var/www/html.’

Step 3/5: It updates the system and installs nginx in the intermediate container.

Step 4/5: Now, it copies the chúng tôi that is created in step 2 above to the current working directory, i.e. ‘/var/www/html’ as we have defined this path using the ‘WORKDIR’ instruction in step 2 in Dockerfile.

Step 5/5: It defines the default command to run whenever the container is created.

d. Now, we can create a container using the newly created image and connect to it to verify everything is as expected:

# cat index.html

Explanation:

In the above snapshot, we can see that we directly landed on the working directory, which WORKDIR set, and when we checked the content of index.html, it is the same file we have copied.

Example #2

Create a Docker image with multiple WORKDIR instructions in the Dockerfile.

a. Here is the Dockerfile for the same.

$vi Dockerfile

RUN pwd

b. Let’s build a Docker image using the above Dockerfile.

docker build –t multi-workdir .

Output:

Explanation:

In the above snapshot, we can see that in step 5/5, the Docker daemon output the present working directory, and that is ‘/home/my_home/Desktop.’ So it looks like changing the directory.

c. Just to cross-check, we can create a container using this Docker image and connect to it as below:

docker exec -it my-cont sh

Explanation:

The above snapshot shows that the current working directory is the same as mentioned above.

Note: ‘sleep 3600’ is used to keep the container running.

Example #3

Use environment variable in WORKDIR instruction.

a. Here is the Dockerfile for the same:

$vi Dockerfile

RUN pwd

b. Let’s build a new Docker image using the above Dockerfile:

docker build -t env-workdir .

Output:

Explanation:

 In the above snapshot, the Docker daemon sets the environment variable ‘DIRPATH’ to ‘/home/my_home’ in step 2/4. It replaces the environment variable in the next step with it when we have used it in WORKDIR instruction. When we check the current working directory in the last step, we can see that it has set the working directory as expected.

Advantages of Docker WORKDIR

First, it saves our time to write the full path repeatedly in the Dockerfile.

Second, it makes us understand the Dockerfile easily by removing the mess of long paths.

Third, it improves the clarity and readability of the Dockerfile.

Rules and Regulations for Using a WORKDIR

Given below are the rules and regulations mentioned:

We should use an absolute path while defining WORKDIR instruction for reliability.

We can only use the environment variables that are defined in the same Dockerfile.

ENV must be defined in the Dockerfile before using it in the WORKDIR instruction.

Conclusion

The ‘WORKDIR’ instruction is very useful instruction to remove the clutter from RUN, CMD, ENTRYPOINT, etc., instructions in which we need to define the path. Therefore, it is recommended to use WORKDIR in the Dockerfile.

Recommended Articles

Docker Stop Container

Docker Volume

Docker Push

Docker Architecture

Guide To Types Of Php Annotations With Examples

Introduction to PHP Annotations

PHP annotations are basically metadata which can be included in the source code and also in between classes, functions, properties and methods. They are to be started with the prefix @ wherever they are declared and they indicate something specific. This information they provide is very useful to coders, helpful for documentation purposes and also an IDE may use this to display certain popup hint kind of things. The same annotation can also be used for other purposes besides validation such as to determine what kind of input needs to be given in a form and also for automation purposes. There are various kinds of annotations like the @var and @int types which can be used for specific uses as their name itself suggests.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax class Example { public $new; }

Annotation is @var here and whenever it is encountered just before the piece of any code (public $new here for example) it indicates that the $new is to have a value of type integer as told by the annotation.

class Example { public $shop; }

Annotations can also be used for specifying the range where it displays the maximum and the minimum values that are to be accepted as integer values for the function and the label gives the purpose of this function.

Types of PHP Annotations

Given below are the types:

1. Built-in Annotations

There are 2 built-in functions in annotations which are as follows:

a. Compiled: This annotation indicates that if the method/function should be JIT compiled or not. It is also a function scope type of annotation.

b. SuppressWarnings: This is another built-in annotation which means that any warnings thrown as part of the execution of the succeeding code below it must be suppressed.

2. Meta Annotations

These are those type of annotations which can be used to apply for other annotations. They are used for configuration of annotations.

a. @Annotations

There is a kind of annotation classes which will contain @annotation.

Code:

[@Annotation] class MyAnnoExample { }

b. @Target

As the name suggests, this annotation indicates those types of class elements or a method upon which the annotation will be applicable.

Property annotation is just before the property class declaration.

Class which is allowed before the declaration of class.

Function is declared before the function declaration.

Method annotation allows proceeding the method declaration.

Annotation is allowed for proceeding to declaration of annotation class.

c. @Repeatable

This annotation means that it may be repeated any number of times when being used.

d. @Inherited

This can also be used on the other user defined annotation classes as a meta-annotation. These inherited annotations are automatically inherited to the respective sub-classes when they are used upon a superclass.

3. Custom Annotations

These are very similar to declarations of the normal class. Each element of the annotation type is defined by each of the property declarations.

Examples of PHP Annotations

Given below are the examples mentioned:

Example #1

Code:

[@Annotation] [@Target("class")] class MyAnnoEx { [@Required] public string $prop; public array $arrayProp = []; public embedAnno $embed; } [@Annotation] [@Target(["class", "annotation"])] class embedAnno { } [@Annotation] [@Target("property")] class propAnno { } @Annotation @Target("method") class methodAnno { public string $val; public function __construct(string $val) { } }

This is just a basic example showing the usage of all the different types of annotations which are shown above. All the ones in the example like embed annotation, property annotation, method annotation are custom annotations.

Example #2

<?php /** * @Replace(“exmaple”, “for”, “annotation”) */ class MyNamedComponent { } echo str_replace(“First”, “Second”, “First Example”);

Output:

In this example we are naming the annotation as replace since the below code represents the usage of string replace function which is str_replace, an inbuilt function of PHP. Using this function, the first parameter passed in the function is replaced by the second one.

Example #3

Code:

<!–Declaring First name for the form First_Name: <!–Declaring Last_Name for the form Last_Name: <!–Declaring Location for the form Stay location: <!–Declaring EMAILID for the form EmailID: <!–Declaring Password for the form Password: <!–Declaring Password for the form Gender: <input type=”radio” value=”Male” <input type=”radio” value=”Female” <?php if(example($_POST[‘confirm’])) { if(!example($error)) { } }

Output:

In this example, we are showing annotations in combination with the form validation in PHP. Using annotations we are labeling all the parameters which are required as input parameters to the form such as first and last name, email, location and password.

Conclusion

With the above examples we have noticed how annotations are a powerful tool to use and express metadata about our methods, classes or properties. We have also seen how to combine different kinds of annotations to declare workers who will perform certain tasks by writing some metadata about them. This makes them easy to find and gives actual information on whether or not they can be used.

Recommended Articles

This is a guide to PHP Annotations. Here we discuss the introduction to PHP annotations with types of annotations and respective examples. You may also have a look at the following articles to learn more –

Complete Guide To Mystery Number

Introduction to Mystery Number

The Mystery number is defined as a number which we get by sum up of two the numbers and that two numbers should be the reverse of each other, this is a unique number, to find that number must be of two digits, then break the number into two numbers such as ‘A’ and ‘B’, if the digit of ‘A’ is reverse of ‘B’ or the digit of ‘B’ is reverse of ‘A’, then that number is said to be a Mystery number, to get this number split the number into two number in which the unit digit and tens digits are interchanged.

Start Your Free Software Development Course

Logic behind Mystery Number

In the above introduction, we saw that a number is said to be a Mystery number if that number can be got by sum up of the two numbers and that two numbers must be reverse of each other, and that number may lie between 22 and 198 because these are the multiples of 11 in the decimal numeration.

Let us see the logic behind using decimal numeration.

If a number is split into two digits numbers so that its unit digit and ten digits are interchanged or reversed then we have to use logic as given below.

Suppose N is a unit digit and M is a 10-digit then the original number will be 10M+N

If we interchange the unit and tens place, then we get 10N+M

Then we get a number i.e., hence we can write it as Mystery number = 10M+N+10N+M

By solving the above, we get the equation as 11M+11N

11 is common in above, so take it common, hence we get 11(M+N)

In this case, M and N can be replaced by any whole number, also we can say that we can use this case when the condition is given in a two-digit number.

Let us see some examples by using the above equation.

Put the values of M and N in the above equation.

11(2+2) = 44 = 22 + 22

In this way we can find the number.

How to Check Mystery Number?

If we have a number first check that number must be a two-digit number.

Then break that number into two numbers, and two numbers which we get that also be two-digit numbers.

After that check whether the digit of one number is the exact reverse of the second number or we can say that numbers digits must be interchanged.

If two numbers are in reverse of each other, then that number is a Mystery number, otherwise, it is not.

Examples of Mystery Number Example #1

Java program to check whether the given number.

Code:

import java.util.*; class Mysterynumber { static int revers(int m) { int sum=0,rem; while(m!=0) { rem=m%10; sum=sum*10+rem; m=m/10; } return sum; } public static void main(String[] args) { int num,i,f=0; Scanner sc=new Scanner(System.in); System.out.println("Enter any number :"); num=sc.nextInt(); for(i=1;i<num;i++) { if(i+revers(i)==num) { System.out.println("This is a Mystery number"); f=1; break; } } if(f==0) System.out.println("This is not a Mystery number"); } }

Output:

In the above example, we have written java code to check the entered number. For that, we take a class ‘Mysterynumber’ and defined one method ‘revers()’ to reverse the given value and used while loop for a condition if that condition is true then it will return the yes it is a Mystery number if the condition is false then returns that is not and to import of package is also necessary, as we have done at the first line of the program. In main() method called the defined functions to check a number is a Mystery number or not. The screenshot is given for the reference of the output.

Example #2

Code:

import java.util.Scanner; public class MystNumber { static int reverse(int a) { String strn = Integer.toString(a); String string=""; { string=string+strn.charAt(i); } int rev=Integer.parseInt(strn); return rev; } static boolean MystNum(int num) { for (int z=1; z <= num/2; z++) { int y = reverse(z); if (z + y == num) { System.out.println( z + " " + y); System.out.println(num+ " is a mystery number."); return true; } } System.out.println("The given number is not a mystery number."); return false; } public static void main(String args[]) { Scanner sc=new Scanner(System.in); System.out.print("Enter a number: "); int num = sc.nextInt(); MystNum(num); } }

Output:

In the above example, we have written a java program to check the given number is Mystery or not with its sum up of two numbers as shown in the above screenshot. For the writing program, we take a class ‘MystNumber’, and define a static function to reverse the given number, in that took a string to convert the number into a string that string has been stored and reverse of the string also been stored. Define a function to check by reversing and comparing two numbers put a print statement to show two numbers which get from a given number, put conditions to check the given number if the condition is true then it will show the given number is a mystery number and if condition false then returns this is not a mystery number.

Conclusion

In the above article we conclude that this is a unique number and to find it we must have to follow conditions, and if conditions are true then and then only we will get that number, some logic and steps are explained in this article which will help to find the Mystery number.

Recommended Articles

We hope that this EDUCBA information on “Mystery Number” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Php Ajax Tutorial With Example

What is Ajax?

AJAX full form is Asynchronous JavaScript & XML. It is a technology that reduces the interactions between the server and client. It does this by updating only part of a web page rather than the whole chúng tôi asynchronous interactions are initiated by chúng tôi purpose of AJAX is to exchange small amounts of data with server without page refresh.

JavaScript is a client side scripting language. It is executed on the client side by the web browsers that support JavaScript.JavaScript code only works in browsers that have JavaScript enabled.

XML is the acronym for Extensible Markup Language. It is used to encode messages in both human and machine readable formats. It’s like HTML but allows you to create your custom tags. For more details on XML, see the article on XML

Why use AJAX?

It allows developing rich interactive web applications just like desktop applications.

Validation can be performed done as the user fills in a form without submitting it. This can be achieved using auto completion. The words that the user types in are submitted to the server for processing. The server responds with keywords that match what the user entered.

It can be used to populate a dropdown box depending on the value of another dropdown box

Data can be retrieved from the server and only a certain part of a page updated without loading the whole page. This is very useful for web page parts that load things like

Tweets

Commens

Users visiting the site etc.

How to Create an PHP Ajax application

We will create a simple application that allows users to search for popular PHP MVC frameworks.

Our application will have a text box that users will type in the names of the framework.

We will then use mvc AJAX to search for a match then display the framework’s complete name just below the search form.

Step 1) Creating the index page

chúng tôi

HERE,

“onkeyup=”showName(this.value)”” executes the JavaScript function showName everytime a key is typed in the textbox.

This feature is called auto complete

Step 2) Creating the frameworks page

chúng tôi

<?php $frameworks = array("CodeIgniter","Zend Framework","Cake PHP","Kohana") ; $name = $_GET["name"]; $match = ""; for ($i = 0; $i < count($frameworks); $i++) { if (strtolower($name) == strtolower(substr($frameworks[$i], 0, strlen($name)))) { if ($match == "") { $match = $frameworks[$i]; } else { $match = $match . " , " . $frameworks[$i]; } } } } echo ($match == "") ? 'no match found' : $match; Step 3) Creating the JS script

auto_complete.js

function showName(str){ if (str.length == 0){ document.getElementById("txtName").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari } else {// code for IE6, IE5 } } } }

HERE,

“if (str.length == 0)” check the length of the string. If it is 0, then the rest of the script is not executed.

“if (window.XMLHttpRequest)…” Internet Explorer versions 5 and 6 use ActiveXObject for AJAX implementation. Other versions and browsers such as Chrome, FireFox use XMLHttpRequest. This code will ensure that our application works in both IE 5 & 6 and other high versions of IE and browsers.

Step 4) Testing our PHP Ajax application

Type the letter C in the text box You will get the following results.

The above example demonstrates the concept of AJAX and how it can help us create rich interaction applications.

Summary

AJAX is the acronym for Asynchronous JavaScript and XML

AJAX is a technology used to create rich interaction applications that reduce the interactions between the client and the server by updating only parts of the web page.

Internet Explorer version 5 and 6 use ActiveXObject to implement AJAX operations.

Internet explorer version 7 and above and browsers Chrome, Firefox, Opera, and Safari use XMLHttpRequest.

Update the detailed information about Complete Guide On Php Compiler With Zend Engine on the Minhminhbmm.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!