Php Interview Question And Answer Pdf

File Name: php interview question and answer .zip
Size: 26432Kb
Published: 20.04.2021

So in this example, strpos returns 0 which is then coerced to false when referenced in the if statement. The correct solution would be to explicitly compare the value returned by strpos to false as follows:.

Core PHP Interview Questions

So in this example, strpos returns 0 which is then coerced to false when referenced in the if statement. The correct solution would be to explicitly compare the value returned by strpos to false as follows:. Note that we used the! If we use! Explain your answer. Interestingly, when this conversion is performed, the leading 0 is ignored and the value is treated as a decimal rather than octal value, so the values are bother decimal and are therefore equal.

And to make matters worse, this is not documented well at all in the PHP documentation. This also explains why the first warning complains about argument 2 and the second warning complains about argument 1. The fix for this is straightforward. If we simply typecast the second argument to an array , we will get the desired results. Surprisingly to many, the above code will output bool true seeming to imply that the and operator is behaving instead as an or.

This is, incidentally, a great example of why using parentheses to clearly specify your intent is generally a good practice, in any language. PHP supports automatic type conversion based on the context in which a variable or value is being used.

If you perform an arithmetic operation on an expression that contains a string, that string will be interpreted as the appropriate numeric type for the purposes of evaluating the expression. So, if the string begins with one or more numeric characters, the remainder of the string if any will be ignored and the numeric value is interpreted as the appropriate numeric type. On the other hand, if the string begins with a non-numeric character, then it will evaluate to zero.

The key here is for the candidate to know that PHP handles large integers by converting them to doubles which can store larger values. Again, the key here is for the candidate to know that the value will be displayed as a negative number, not to know the precise value.

How would you sort an array of strings to their natural case-insensitive order, while maintaing their original index association? The trick to solving this problem is to use three special flags with the standard asort library function:. The function asort is a variant of the standard function sort that preserves the index association. Note: Using the natcasesort function would not be a correct answer, since it would not maintain the original index association of the elements of the array.

PEAR is a code repository containing all kinds of php code snippets and libraries. Both are used to output data to the screen. Perhaps surprisingly, the answer is neither NULL nor When a hex string is loosely compared to an integer, it is converted to an integer.

Note that this only works for hex strings, not for octal or binary strings. Note, in PHP 7. Traits are a mechanism that provides some of the reuse advantages of multiple inheritance in languages like PHP where multiple inheritance is not supported.

Traits enable developers to reuse combinations of methods from different class hierarchies. How can this code be fixed to work correctly?

What will be the output of the code below and why? What will be the output of each of the statements below and why? What is the problem with the code below? What will it output? How can it be fixed? What will this code output and why? The correct answer is Please note that as of PHP 7. There are two things going on here. What is PEAR in php? PEAR also offers a command-line interface that can be used to automatically install packages.

What are the differences between echo and print in PHP? The only differences are as follows: echo does not return a value whereas print does return a value of 1 this enables print to be used in expressions.

What is use of the header function in PHP? How can you tell if a number is even or odd without using any condition or loop? What is the difference between a session and cookies? What does the follow code echo? The number 1. Write a sample of code showing the nested ternary conditional operator in PHP. What are Traits? At the end of the day, hiring remains an art, a science — and a lot of work. Submit a Question.

Thanks for submitting your question. Our editorial staff will review it shortly. Design your career as a PHP developer with Toptal. Ciprian enjoys coding a lot and he collected substantial experience in different domains. He thinks the more programming languages you know, the better programmer you are. His specialties are security and highly-concurrent backend systems but he also likes doing front end, DevOps, and automated tests.

Ciprian enjoys taking his responsibilities seriously so that every task is completed in the best way possible. Hire Ciprian. Fahad Murtaza United Arab Emirates. He has also worked with Zend and Symphony framework and is currently focusing on Go and Python.

Fahad has provided solutions using a number of JavaScript technologies including Node. Hire Fahad. Bruno Costa Portugal. Bruno is a full-stack developer with a background in engineering and a massive passion for the product side.

What Bruno is currently up to is mentoring the Ruby track on the site Exercism. Some words that come to mind when describing Bruno are assertive, relentless, and optimistic. Hire Bruno.

PHP Interview Question and Answers for Freshers

Last week I met one of my old friend. He had done a course in PHP from one local institute. But their training was terrific. He asked me to prepare some basic questions that generally asked for PHP job interviews. I asked him a simple questions first. Whats the full form of PHP? After seeing his endless thinking, I started to answer.

It is a widely used open-source programming language especially suited for creating dynamic websites and mobile API's. PHP: Hypertext Preprocessor is open source server-side scripting language that is widely used for creation of dynamic web applications. PHP automatically converts the variable to the correct datatype , depending on its value. PHP sessions are stored on the server generally in text files in a temp directory of the server. That file is not accessible from the outside world.

PHP Interview Question and Answers

What is the difference between a static and Dynamic Web site? What is the meaning of Open Source Software? Why was PHP developed, what it is used for, and where can you get it?

PHP is a web language based on scripts that allow developers to dynamically create generated web pages. It extends PHP and provides a higher level of programming for web developers. Version 7.

Preparing for a PHP interview?

Echo and print both are the PHP statement that is used to display the output. Multiplie argument can pass separated by , in echo statement. But using print statement single argument can pass. Echo is faster than print statement. Get is a unsecured method because it displays all the information in address-bar url while POST hides all the information so it is secure method.

PHP Interview Questions PDF

 - Почему вы считаете, будто Танкадо не знал, что на него совершено покушение. Смит откашлялся. - Халохот ликвидировал его с помощью НТП - непроникающей травматической пули. Это резиновая капсула, которая при попадании растворяется. Все тихо и чисто.

Top 50 PHP Interview Questions You Must Prepare in 2021
1 Response

Leave a Reply