A one-line description of the project

PHP programming language is one of the most widely used and popular programming languages ​​in the field of web development (backend) and a high percentage of websites and web applications in Iran and around the world are created with PHP. This programming language is still very popular and many companies are looking to hire PHP‌ programmers. Therefore, this article presents some of the key PHP programming interview questions. This article is a guide to hiring PHP programmers at the beginner to advanced levels.

· Table of contents of this post

· PHP Programming Interview Questions for Beginners

· Introducing PHP programming training videos

· Intermediate PHP Programming Interview Questions

· PHP Programming Interview Questions for Experienced People

· Other PHP programming interview questions

· PHP Programming Interview Questions (Personality)

· PHP training videos

· Conclusion

Show all

The introductory part of the article "PHP Programming Interview Questions" refers to the questions that novice programmers need to be able to answer.

PHP Programming Interview Questions for Beginners

This introductory part of the article addresses PHP programming interview questions at beginner and advanced levels. Beginners in the field of programming can improve their skills for growth and prosperity in this popular field by becoming familiar with such questions. In addition, by familiarizing yourself with the PHP programming interview questions provided in this section, individuals can prepare for the job interview and increase their chances of being accepted and hired for the job.

What is the difference between variables and constants in PHP?

Each of the key differences between variables and constants is as follows:

In PHP, the value of a variable can be changed during execution, but it is not possible to change a constant value during script execution.

To use variables, you must use the $ sign at the beginning, while you do not need the dollar sign ($) before using the constant.

In order to define a variable, only a simple assignment is needed. But constants cannot be defined by simple assignment, and the define () function must be used to define them.

In variables, the default Scope is the current access range. If it is possible to access the constants universally and without restrictive rules.

What is a Session in PHP?

In PHP, a session is a way to store information that is used for multiple pages of the entire website. Unlike cookies, information is not stored on the user's computer. In a temporary folder on the server, a file is created by Session in which session variables are stored and their values ​​are stored. It should be noted that during that visit, the mentioned information is available on all pages of the site. When a user works with an application, they open that application, make changes, and then close it. This operation is very similar to Session.

PHP Programming Interview Questions

When working with a computer, it is clear who the person is, when he or she started the program, and when it ends. But on the Internet, no specific information is available to the web server about who the user is or what they are doing. Because no status is maintained in the HTTP address. This problem can be solved using session variables. Due to session variables, it is possible to store user information for use on multiple pages. For example, you can save your username, favorite color and other user information. By default, session variables will last as long as the user closes the browser. Therefore, in Session variables, a user's information is stored and this information is available for all pages in an application.

What is PEAR in PHP?

PEAR stands for PHP Extension and Application Repository. PEAR is a framework and repository for all reusable PHP components. PEAR allows web developers to program at higher levels. PEAR, on the other hand, offers a variety of PHP code snippets and libraries, as well as a command-line interface for automatically installing packages.

· We suggest: Programming PHP and everything you need to know to get started - Training

· What is the difference between message $ and message $$ message?

· The most important differences between message $ and $ $$ message are as follows:

· message $ is a normal variable, but $$ message is a reference variable.

· message $ has a fixed name and a fixed value is stored in it, but $$ message was created to store variable data.

· The data stored in message $ is fixed. While changing the value of the variable, the value of message $$ may change dynamically.

· PHP interview questions

· Is PHP a case sensitive language?

PHP can be thought of as a language that is designed to be partially case-sensitive. In fact, the names of variables are completely case sensitive, but in function names there is no case sensitivity. On the other hand, there is no case for case-defined functions in PHP for naming user-defined functions, but this language is case sensitive for other cases. This means that in PHP it is possible to name user-defined functions in lower case, but later call them in capital letters in the program. In such cases, the code still works properly.

What are the types of variables in PHP?

There are generally eight basic types of data in PHP that are used to construct variables. The following are the types of variables available in PHP:

Integers Type: Integers are floating-point integers. For example, the number 1253 is an Integer.

Type : Doubles: This type of variable is the same as floating point numbers, for example 7.876 is a Double.

Boolean data type: Boolean is used to represent two logical states. For example, right and wrong are two Boolean values.

NULL type : NULL data type is a special type that has only one value. When no value is assigned to a variable, the NULL value can be assigned to it.

Array Type: Arrays are a named, regular set of similar data types. For example, the command line expression is below an array.

colors = array ("red", "yellow", "blue");‎$

String Type: Strings are a sequence of characters. For example, “Hello! Interview Bit is a string.

Resource Type: Resources are specific variables that consist of references to external PHP resources (such as database connections).

Object data type: are examples of classes containing data and functions. For example, mango = new Fruit (); $ is an object.

Types of variables available in PHP

What are the rules for naming a PHP variable?

The following rules must be followed when naming a variable in PHP:

· The variable must start with the dollar symbol and then its name. For example, in price = 100; $ a variable named price is defined in which the value is 100.

· Variable names need to start with a letter or a hyphen.

· Variable names can include letters, numbers, or underscores. But it is not possible to use characters such as +, -,% and others.

· PHP variable name cannot contain spaces.

· PHP variables are case sensitive. Therefore, NAME $ and name $ are both considered as different variables.

· What is the difference between Echo and Print in PHP?

· The main differences between Echo and Print in PHP are listed below:

· Echo can display one or more strings in the output. However, Print can only display one string as output and always returns 1.

· Because Echo does not return any values, it is faster than Print.

· If more than one parameter needs to be passed to Echo, parentheses should be used. In Print, it is not necessary to use parentheses for the argument list.

· Disadvantages of PHP in PHP Programming Interview Questions

· What are the disadvantages of PHP?

· Although PHP is a popular application language in web programming and is still used as a powerful language, like other programming languages, it has a number of minor drawbacks. The following are some of the shortcomings of PHP.

1. PHP is not suitable for web-based content applications.

2. Because PHP is open source, it is not secure. Because it is easy to access ASCII text files.

3. PHP is not allowed to change the basic behavior of online applications.

4. If more features of PHP frameworks and tools are used, it may weaken the performance of online applications.

5. PHP has a low quality error handling.

6. PHP does not have the necessary debugging tools to search for warnings and errors. In fact, PHP has only a few debugging tools compared to other programming languages.

7. What is the difference between a local and a global variable in PHP?

8. The local variable is declared inside a function, while in the Global variable ‌ it must be declared outside the function.

Local variables are created when the function starts to run and disappears when that function ends. In contrast, the global variable is created at the beginning of the execution and will disappear at the end of the program.

It is not possible to share data using the local variable, but data can be shared using the global variable.

Local variables are stored in the stack, while the global variable is stored in a fixed location specified by the compiler.

For local variables it is necessary to send parameters, while for global variables there is no need to send parameters.

What is meant by abstract methods and classes in PHP?

Classes and methods are abstract when the parent class contains a method with a name, but at the same time, the child's class or classes are needed to complete the tasks. In PHP in general, an abstract class is a class that is largely implemented by any developer. An abstract class may have at least one abstract method, which is basically written without code and has only different names and parameters.

We suggest object-oriented programming in PHP and explain the concept of class and object - in plain language

What is the role of PHP programmer in software development?

A PHP programmer works as part of a team in developing clients' web-based applications. Depending on the client's needs, the key tasks of this job include writing PHP scripts and coding to create or modify software and applications. In addition, the PHP programmer has other tasks such as troubleshooting various errors or issues related to PHP programs and creating documentation for them. In the following, the tasks of a PHP programmer will be discussed in more detail.

· Work closely with the IT team to complete projects

· Troubleshoot any PHP applications

· Ensure proper operation without violating web processes and infrastructure

· Create scripts to facilitate client systems to achieve the desired performance and goals

· Software testing and development for client applications

· Create documentation for the created software

· Debugging the source and writing or modifying the client software

· Deliver results effectively and on time

· What is the difference between abstract classes and interface classes?

The function of Abstract Class and Interface Class in PHP is similar to other Object Oriented Programming Languages ​​(OOP) . The main differences between abstract classes and interfaces are listed below:

· In abstract classes, not all methods need to be abstract. But in the interface must be any abstract method.

· Interface methods must be public. Abstract class methods, however, can be considered general or protected.

· The interface supports multiple inheritance, but abstract classes cannot support multiple inheritance.

· Interfaces cannot have properties, while abstract classes do.

· All methods of an interface are abstract, so they can not be implemented in code and do not require an "Abstract Keyword".

· This section examines a variety of PHP programming interview questions, as well as some introductory programming questions. The following are some of Faradres PHP programming training courses.

· Introducing PHP programming training videos

· PHP Tutorial Collection PHP Programming Training | Introductory to Advanced | PHP programming questions

Due to the importance of PHP language in the background of web programming, like other widely used languages, a set of PHP programming training courses is also offered on Faradres site. This collection includes more than 10 different training courses at the time of writing this article. After reading the "PHP Programming Interview Questions", you can continue the PHP‌ learning path by enrolling in any of the other courses in this series. These courses include working with frameworks, libraries, and providing PHP project-based tutorials.

PHP programming training video (Time: 28 hours and 31 minutes, Instructor: Dr. Seyed Mostafa Kalami Harris): In this training course, all the tips and practical skills needed to enter the fascinating world of web programming and implement websites, to It is taught in the simplest and most fluent way possible and in a completely practical way. To access the training videos and Matplotlib work with NumPy libraries in Python + click.

CodeIgniter PHP Framework Tutorial Video (Time: 7 hours, Instructor:): In this course, the method of creating a fast and principled website based on teamwork and MVC model is described comprehensively and practically. Click CodeIgniter + to access the PHP tutorial video page.

Video tutorial for making online store software with CodeIgniter framework (time: seven hours and 17 minutes, instructor: Omid Najafipour): In this training course, first the basic principles of an online store are examined and then, CodeIgniter framework is project-oriented. And is used to design a simple yet comprehensive online store. Click to access the video tutorial page of building online store software with CodeIgniter + framework .

Video tutorial for regular expressions in PHP (Time: 4 hours and 16 minutes, Instructor: Hayat al-Ghayb): This training course is suitable for people who want to learn how to work with regular expressions using PHP language. Click PHP + to access the regular phrase tutorial video page .

REST API training video in Laravel (Passage package) (Time: 2 hours and 57 minutes, Instructor:): In this training course, a system is introduced that has already been developed and created using Laravel. Then, by recognizing and examining the concepts related to creating a RESTful API for the mentioned system, the implementation of the relevant concepts is described. This course is suitable for people who want to learn how to create APIs for such systems. Click on the Passport + package to access the REST API training video page in Laravel.

PHP project-based training video - Building a search engine for a website (Time: 2 hours and 29 minutes, Instructor: TargetedWebTraffic): This training course is suitable for people who want to get acquainted with the tricks of building a suitable search engine and can Use it in your software or website and even customize it according to your taste and needs. It should be noted that this engine is written based on PHP language. Click to access the PHP project-oriented training video page - Build a search engine for the website +.

Video tutorial on working with AJAX in PHP and MySQL (Time: 2 hours and 13 minutes, Instructor:): In this tutorial, how to use the AJAX method from the jQuery library and implement AJAX technology in a PHUD project in PHP And are comprehensively reviewed using the MySQL database. Click to access the AJAX tutorial video page in PHP and MySQL +.

To access the tutorials of programming PHP + click.

By using the above training courses, you can learn the concepts of PHP programming from basic to advanced level in a comprehensive and at the same time simple language. The following is an overview of intermediate ‌ PHP programming interview questions.

Intermediate PHP Programming Interview Questions

In this part of the article "PHP Programming Interview Questions", those common questions are answered whose difficulty level is in the middle and middle level.

How can PHP and HTML interact?

PHP scripts have the ability to generate HTML and can transfer information from HTML to PHP. PHP is a server-side language, while HTML is a client-side language. Hence, PHP runs on the server side and the results will be received as strings, objects, arrays. After this step, they are used to display the corresponding values ​​in HTML. Using an interactive approach, in addition to filling the gap between HTML and PHP, their use is facilitated in the best possible way.

What is the purpose of having @ in PHP?

In PHP, @ is used to suppress error messages. If a runtime error occurs on a line that initially has an @ sign, the error is handled by PHP.

Recommended article: Creating a login form with PHP - from zero to one hundred

What is the importance of Parser in PHP?

PHP Parser is software that converts source code into computer-understandable code. This means that any set of instructions provided in PHP code by Parser will be converted to machine readable template. Using the token_get_all () function, it is possible to parse PHP code using it.

· PHP programming interview

· What are the different types of arrays in PHP?

· In PHP, three types of arrays are used, which are mentioned below.

· Indexed Array: An array that is identified by a numeric key in which values ​​are stored in linear order and are accessible.

Associative Array: Those arrays that are used to index the elements of a string. Instead of storing element values ​​linearly and flexibly, these values ​​will be associated with key values.

Multidimensional Array: The group of arrays in which one or more other arrays are placed is known as a multidimensional array. Values ​​stored in multidimensional arrays are accessible using multiple indicators.

How to generate random numbers in PHP?

To generate a random number in PHP, you can use a built-in (Built-in) function called rand (). This function takes two arguments as the desired interval. If the function is written in rand (min, max), min and max are used to determine the minimum and maximum range of numbers to produce this function, respectively. In case no value is set for min and max, by default, the values ​​of zero and getrandmax () will be set for them, respectively. Thus, with the help of the rand () function, it is possible to generate a random number in the range 0 to grandma (). For example, if this function is used as a rand (15,35 ), it will generate a random number between 15 and 35.

· Programming interview questions

· What are the main types of errors in PHP?

· There are basically three types of errors in PHP that are addressed below.

Notices: Notifications of non-critical errors that may occur while executing a script. This type of error is not visible to users. For example, accessing an undefined variable is an example of a Notice error.

Warnings: These errors are more important than other errors. Of course, warnings do not stop the script from running. By default, these are visible to users. For example, these errors will appear if include () of an missing file.

Fatal: This is the most critical type of error, and if it occurs, the script will run immediately. For example, accessing a property from a non-existent object or require () to a file is of the Fatal error type.

What are traits in PHP?

traits is a mechanism used to reuse code in single inherited languages ​​such as PHP. The purpose of the Trait is to reduce some of the limitations of hereditary languages. In fact, this is done by making it possible to reuse method sets freely in several independent classes in the hierarchy of different classes. Combined semantics Trait and classes are defined in a way that reduces complexity and thus avoids common problems associated with multiple inheritance and combinations. Trait is similar to class, but is used only to group functions in a precise and consistent manner. A Trait alone does not have the ability to prototype.

Does JavaScript interact with PHP?

JavaScript is a client-side programming language, while PHP is a server-side programming language. PHP has the ability to generate JavaScript variables and can be easily run in a browser. This makes it possible to transfer variables to PHP using a simple URL.

How does foreach loop work in PHP?

The foreach command is a loop structure used in PHP to repeat and create loops through array data types. Foreach is easy to work with, so sending a value to the elements of a value is assigned and the pointers increase. This process is repeated until the array is complete. The syntax for using the foreach command in PHP is as follows:

foreach($array as $value)

{

Code inside the loop;

}

What is the most common way to hash passwords in PHP?

In PHP, the crypt () function is used to hash passwords. This is because there are several hashing algorithms available and it is possible to use them. These algorithms include sha1 , sha256 or md5 , which are designed to be very fast and efficient.

What is the difference between the include () and require () functions ‌?

The include () function is used to copy all the contents of a called file into text, in the text of the file being called. When the included file is not found, only a warning (E_WARNING) will be generated and the script will continue to run. The require () function works like the include () function. In addition, the required file is used using the require () function, and the entire code will be copied to the file from which the require () function is called. When the included file is not found, a fatal error will occur (E_COMPILE_ERROR) and then the script will be terminated.

PHP programming language in the content of PHP programming interview questions

What is the Unlink () function and how does it work?

The Unlink () function is a built-in (Built-in) function in PHP that is used to delete a file. For this purpose, to delete the desired file, the name of the relevant file is sent as a parameter and if the function succeeds, it returns the value True and in case of failure returns the value False. It should be noted that in PHP, the Unlink () function accepts two parameters.

What is the difference between Unset () and Unlink () functions?

Although both functions are used to perform some neutralization operations, the two functions are different due to their different functions under different conditions. The Unlink () function is used when files need to be completely deleted, and the Unset () function is used when the goal is to empty the file.

What is a cookie and how to create a cookie in PHP?

A cookie is a small record that is installed by a server on a client computer. Cookies store data about a user in the browser and are used to identify the user. When a user requests a specific page, cookies are embedded on their computer. A cookie will be sent each time a page application is requested on a similar computer. After the user is authenticated in encrypted form, the session ID generated by the cookies is backed up. Of course, it should be noted that the cookie must be in the device browser. It is only possible to store string values.

PHP interview

For example, an object cannot be saved; Because it is not possible to access objects on the website or web applications. By default, cookies are specific URLs. For example, Gmail cookies are not supported by Yahoo and Yahoo cookies are not supported by Gmail. Simply put, cookies are temporary and transient by default, and you can create up to 20 cookies per site or web application. The minimum initial cookie size is 50 bytes and the maximum is 4096 bytes. In PHP, cookies can be created using the setcookie () function. The following is a general definition of a cookie and an example of how to create one.

;setcookie(name, value, expire, path, domain, safe, httponly)

The above line of code is the general form of the cookie definition. In this command, the name parameter is mandatory and the remaining parameters are optional. For a better understanding, consider the following example:

setcookie ("instrument_selected"، "guitar")

What is the difference between ASP.NET and PHP?

The main differences between ASP.NET and PHP are listed below:

ASP.NET is a web application software framework, while PHP is a server-side programming language.

ASP.NET is designed for use in Windows, but PHP is a standalone platform. This means that it is possible to use PHP on different platforms.

In PHP the execution method is interpreted, but in ASP.NET the code is compiled and executed.

ASP.NET has a related license fee, but PHP is available as free open source software.

What is the meaning of Escaping To PHP?

PHP parsing engine needs a way to differentiate PHP code from other elements of the page. The mechanism for achieving this is known as "PHP escape". For example, "escape from a string" means to reduce the ambiguity in the "" sign used in that string. For example, if the string "Hello, InterviewBit" is defined using the "" or "sign, there is no problem. But what if the "" sign is used again in this field? For a better understanding, refer to the "Hello" InterviewBit "string. There is ambiguity in this field. Because the interpreter does not have the ability to know the end of such a field. If there is a need to preserve these quotation marks, various methods are provided, which are discussed below.

Single quotes can be used around the desired string. That is, it was considered "Hello" InterviewBit. "

It is possible to use the "quote escape" technique. Therefore, the desired string can be written as "Hello \" InterviewBit. \ ". In such cases, any quote preceding a slash is termed Escape and is recognized as part of the string value.

Why use CSS, HTML and JavaScript in web programming?

CSS, HTML and JavaScript are the core components of websites around the world. As a web developer, one uses three main technologies, HTML, CSS and JavaScript, to build a website. HTML is used to structure the site and CSS is used to design and layout the web page and JavaScript is used to add interactive and dynamic capabilities. In general, the front end design of web pages is done with the help of information that has a great impact on the content, style and interaction of the site.

What does AJAX do for you as a web developer?

Ajax provides the best techniques for improving the user experience in a web application. AJAX is derived from the term asynchronous JavaScript and XML and is a technique for creating fast and dynamic web pages. With AJAX, web pages can be updated asynchronously. This feature is provided by exchanging small amounts of data with the server behind the scenes. Simply put, with AJAX, it is possible to update parts of a web page without reloading the entire page.

· Recommended article: Using AJAX in PHP and jQuery - an introductory guide

· PHP programming interview

· What is the meaning of Path Traversal?

Path Traversal is an "attack" to read a web application file. "../" is a "cross-platform" symbol for climbing the list. In Path Traversal, this symbol is used to execute a web application file. An attacker could detect the contents of an attack file by navigating outside the main directory of a web server or application. Commonly used to access secret passwords, tokens and other sensitive information stored in files.

What is the meaning of the final method and the final class?

In the method declaration, the "Final keyword" indicates that it is not possible for the subclasses to cancel the method. A class that is declared a "final class" cannot be subclassed. This is especially useful when you need to create an Immutable class, such as the String class. In fact, only classes and methods can be defined as finite, and Properties do not. In this section and previous sections, PHP programming interview questions at the intermediate and intermediate levels were examined. Now in the next section, some PHP programming interview questions at advanced and professional levels are described. These questions are suitable for people who are experienced in programming with PHP.

PHP Programming Interview Questions for Experienced People

In this part of the article, various PHP programming interview questions that are at advanced levels are addressed.

What are the steps to create a new database using MySQL and PHP?

To create a new MySQL database in PHP, four basic steps are required, which are mentioned below.

Using the PHP script, communication with the MySQL server is done.

In case the connection is confirmed. If the connection is successful, a sample confirmation query can be written.

Queries are considered as input that create the database and will then be stored in a string variable.

After the above steps, the created queries are executed one after another.

What is the use of session_start () and session_destroy () functions in PHP?

The session_start () function is used to start a new session. In addition, if an existing meeting is interrupted, it is possible to resume it. In this particular case, if the session is resumed, it will be a return to the current session. The session_start (); syntax is used to start the session. On the other hand, the session_destroy () function can be used to delete a session. In order to better understand the function of this function, consider the following code snippet:

<?php

session_start();

session_destroy();

?>

What are Memcache and Memcached in PHP?

Memcached is an efficient "caching daemon" designed specifically to reduce the database load in dynamic web applications. Memcache provides a useful procedural and object-oriented interface for Memcached. Simply put, Memcached is a distributed memory storage system that is widely used, often to speed up dynamic database-based websites by storing data and objects in RAM. In fact, in such cases, using Memcached will reduce the number of times you read external data sources.

Is it possible to share a copy of Memcached between multiple PHP projects?

Memcache is a memory storage space and it is possible to run Memcache on one or more servers. For this reason, an instance of Memcache can be shared between multiple projects. It should be noted that a client can be configured to talk to a set of separate instances. Therefore, it is possible to run two different Memcache processes on one host. Despite running on a host, both of these Memcache processes remain independent, unless there is a data partition.

· What are the different ways to manage MySQL portfolio in PHP?

· What are the different ways to manage MySQL result sets in PHP?

· There are four ways to manage the MySQL portfolio in PHP, which are listed below.

mysqli_fetch_array (): Returns the current row of the result set as an associative array, a numeric array, or both.

mysqli_fetch_assoc (): Returns the current row of the result set as an associative array.

mysqli_fetch_object (): Returns the current row of a result set as an object.

mysqli_fetch_row (): Returns the result row as an enumerated array.

How to link to a URL in PHP?

Using a library called cURL, you can easily link to a URL in PHP. Note that cURL is provided by default as a PHP standard installation. The term cURL stands for Client Side URL. CURL uses libcurl (client-side URL transfer library) which provides support for many protocols such as Kerberos, IMAP, HTTPS, HTTP proxy, HTTP PUT, HTTP POST, HTTP / 1 , FTPS, FTP and more. Is. Using cURL, you can link to a URL and retrieve and display information such as HTML content, HTTP headers, and related data from that page.


Questions?

Contact [email] to get more information on the project