Category Archives: PHP

Articles and Interview Questions,Tips related to PHP – Interview Sortout

Skills that Every PHP Developer Must-Have

The popular scripting language PHP, has been in the market for 25 years. Like Python, PHP is also a programming language developed by Rasmus Lerdorf as his side project in the 1990s. 

Although language usage may have been declining over the years, Stack Overflow has shown that PHP is still among the top ten scripting, programming, and markup languages ​​available.

It is used by major websites such as Facebook and Wikipedia and the world’s most significant open-source projects, such as Drupal and WordPress.

PHP development is trendy now, and many freelancers are involved in PHP development. You may be curious to know about How to become a PHP Developer? But If you want to be a successful independent PHP developer, you need to understand more than just PHP. Here are six essential skills you need to succeed as a PHP developer.

Knowledge of Other Programming Languages

If you want to stand out as a PHP developer in the highly competitive job market, it is not enough to understand PHP code. A strong understanding of front-end programming languages ​​such as JavaScript, HTML, and CSS is essential for finding and fixing web design errors.

Familiarity with these languages ​​will also help you better understand how they affect the ultimate goal of most programming projects (which is the user experience).

Understanding the database (primarily MySQL but common alternatives such as Oracle and PostgreSQL) is also essential. In short, acquiring and maintaining comprehensive technical skills is a meaningful way to become a valuable development team member.

Good Communication

You can be a genius with PHP code, but if you do not know how to communicate with others, it can be challenging to work effectively on a team project.

You need to be able to talk to your clients, bosses, and colleagues to understand your project or business goals, ask questions and describe how your work fits into a broader range of products.

Remember that even if you are most comfortable when behind a screen, good communication requires speaking over the phone, through video conference, or in person, as well as through messaging apps and email.

Problem Solving Skills

Learning the “hard” technical skills is one aspect of becoming a leading PHP developer, but you cannot be at the top without the right combination of “soft” skills.

One of them is problem-solving, which is the foundation of all web development. PHP developers face unexpected problems that need to be solved. How you address these problems plays a vital role in the value of the development project.

Critical thinking (where you can analyse and evaluate different solutions to a problem to find the most effective solution) is also vital for writing high-quality code.

Get Comfortable with Composer, PSR, PHPUnit

These are some of the tools that make you a better PHP developer. Composer is a dependency manager that manages libraries, functions, and classes, making it easy for you to install different versions of each on a per-project basis.

Composer checks for new versions of these libraries and updates them as needed. You can find a list of ready-made packages compatible with Composer. The PHP Standard Recommendation (PSR) is a PHP specification that aims to standardize PHP programming concepts and improve the interoperability of PHP frameworks and components.

It is published by the PHP Framework Interoperability Group (PHP-FIG). There are currently 13 recognized standards, each with its purpose.  PHP developers must learn and follow these standards to reduce unnecessary variants in their PHP code.

At the same time, PHPUnit is a popular unit testing framework for automatically testing small units of code based on expected results. Unit testing is a good practice for a PHP developer like you and can be used in a Test-Driven Development (TDD) approach where tests are run even before the code is written.

Networking Skills

Networking with other freelance PHP designers and web development freelancers in other disciplines can help you find more referrals and jobs. Use Twitter, LinkedIn, and Facebook to connect with other developers and customers you work or collaborate with in the past. In the highly competitive job market, networking skills are invaluable.

Get Grip with PHP Best Practices and Design Patterns

Design patterns are very useful in all software development, including PHP. You can speed up development by providing repeatable solutions to common problems.

It also helps improve the readability of the code by identifying patterns used by other developers. Some of the most common design patterns in PHP applications include Factory, Strategy, and Singleton, but many other problems exist.

More generally, when using different PHP frameworks, you can save time by looking for best practices. The language has existed for more than 20 years, and behind it is a huge community. Make the most of this language so as not to make the same mistakes as others did.

What is the Future of PHP?

According to DAXX statistics, there were more than 5 million PHP developers worldwide in 2013, but this number increased to 5.5 million in September 2018. For comparison, the number of software developers worldwide reached 23 million in 2018, 26.4 million in 2019 and expected to reach 27.7 million by the end of 2023, regardless of knowledge of the software development language. New languages ​​may emerge, but PHP is always there, especially if it continues to evolve into more modern languages.

PHP Developer Salary

PHP developers are well paid for their jobs, and there are huge opportunities for you to grow.

According to the Glassdoor survey, in the United States, the annual salary of PHP developers is US$74,126, while in India, the annual salary of PHP developers is Rs 265,507.

According to the Glassdoor article, junior PHP developers (inexperienced and just getting started) can make an average of $74,000 per year.

In contrast, senior PHP developers can make an average of $114,000 per year. Keep in mind that these salaries may be higher or lower, depending on the company’s size, local needs, location, etc.


These six skills are essential for PHP developers. Web development is a highly competitive field and breaking in at the lower levels is challenging. Once you master these skills and start your career as an independent PHP developer, you will enjoy exciting jobs and high salaries.

Spread the love

Latest trends in Laravel Development in 2021

Laravel is a PHP-based application scheme that is used for web development purposes. These are commonly used by many people as they have various added features like a fast-evolving mechanism. This is used to create modular web applications with higher levels of security.

It is very comprehensive, user-friendly, and easy to learn and to comprehend by people. It also allows web applications to be created with a wide number of features, from the basic to the highest level of performance levels.

In addition to the simplicity it upholds, the encoding experience also follows up to performance levels that are errorless and they make use of the Laravel framework or the Top laravel development company.

There are some key trends that have been adopted by Laravel Development. These comprise the database usage, cloud storage features, or database handling. This can be done by Laravel for its application development process. It also offers features that will help one to develop attractive and simple web applications.

The following are the key trends, they are the use of the Model – View – Controller (MVC), trustworthiness, innovative features, safety and security, object based library, base for startup, enhancing PHP and the future prospects of PHP, Laravel and IoT. 

MVC (Model – View – Controller)

Laravel makes complete use of the Model – View – Controller system, which is useful for both the designers and creators. Furthermore, the MVC is used by Laravel which assists in understanding the business logic and also the user interface code that is also useful for this feature.


This is another feature that allows Laravel to be widely accepted and used by the world. This helps to create and develop various websites. This helps in the process of the acceptance and makes this platform a much trusted source for the various developers. This is also very fast, efficient and it is secure. This attracts the attention of many people. This is also very dependable. 

Innovative Features

This allows the market to offer various types of the PHP frameworks that also give a very tough competition to its competitors. In order to remain highly competitive in the market. People have to opt for various innovative features overtime. Furthermore, Laravel is continuously added for its new features and allows other competitors to make use of these. 

Safety and Security

This is another important feature of Laravel framework. This ensures the users are protected well against these cyber crimes. This helps to keep them in good hands. This also ensures that the security features are well incorporated to these platforms.

As the number of cyber crimes are continuously increasing, there is a need for people to safeguard their website from these attacks. This will keep them under protected and secure measures. Furthermore, Laravel aims to provide its users a safe and secure networking system.

Object based library

This is a feature that is followed by many. This allows them to develop the respective framework. This makes use of the pre-installed Laravel library. This also makes use of the support from the large amount of data.

This also makes use of the processing to be done easily. This also comprises the information verifying system. This is of great use to its users. 

Base for Startups

Start ups are a growing field and many people are stepping forward to engage in startups. Laravel is not only a platform that supports the established organisations.

This also makes use of the various framework systems to establish and create a new startup scheme. This allows Laravel to handle large amounts of data that is well protected.

Furthermore, they can also reach out to the various other markets much more easily. This helps to reduce a lot of time wastage from taking place. This also allows for the smooth functioning of the applications. 

Enhancing the Functioning of PHP

It is important to transform a digital world. However,this process can be very challenging and tedious for people to follow. This is mainly due to the organizations which have an aim to gain users and their interest.

This increases their engagement levels. This then leaves room for continuous  improvement in web application creation. Hence in order to lead the market, individuals are trying to provide the best. Hence in the future, PHP is used to save the rapid execution process for the various codes and memory utilization.

This helps to make full use of Laravel as it is the most well-known and trendy framework across PHP.

Future uses of PHP, Laravel, and IoT

This allows the combination of all these networks. This then helps to develop a system which is closely tied and works well together by the collaborative measures.

This also helps to create new applications that are very useful and in building an application that is very clear in their goals and in the process of development. There are many best laravel development companies that are found hence people can seek their help. 

Spread the love

Freelancer PHP Level 1 Exam Questions Answers is an open platform for the skilled person to get projects and jobs according to their expertise. There are many types of projects there like Fixed Price Projects, Hourly and Contests. One can get their job done by an Expert on either side of the globe.

There are options to bid on the project and submit your proposals. The person who is looking for an expert will evaluate your profile , proposal and skill and then after conversation you get rewarded for this project. After successfully completing the stages you will get mile stones created by the Employer.

But at the same time the competition is High and It’s tough to get recognised by the employer. Freelancer provides assessment of the skills of various levels.

You can try these exams or quizzes and after completing it by scoring the appropriate marks set by the Freelancer you will get a badge of the Level of the Skill.

And this badge will make an impact on employers that you have knowledge of a particular skill.


Passing an exam increases your chances to get awarded the project by your employer. In This Section You will get stuff that is really helpful to you in clearing the Freelancer PHP Level 1 Exam. We have listed almost the questions asked in Exam and Answers for the same.

The file handle argument in fread() allows you to specify ___________.

Answer: the number of bytes you wish to read


$count = $count + 8; can be written as:

Answer: $count += 8;


Which of the following is a special PHP variable that is used under HTTP Authentication?



XML is used for:

Answer: All of these

Data manipulation and storage

Display formatted data in a browser using style sheets.

transfer data between organizations

transfer data between software applications


Which kind of reference action allows you to have two variables referring to the same content?

Answer: Assign by reference.


____________ describes the structure of a class of XML documents, specifying how elements are related and allowed.

Answer: Document Type Definition


Which parameter of setcookie() indicates that the cookie should only be transmitted over a secure HTTPS connection from the client?

Answer: secure


Which of the following can be included in a phar file?

Answer: All of these

a manifest describing the contents

a signature for verifying integrity

a stub

the file contents


Which of the following will encrypt a password?

Answer: crypt($password);


Which of the following will connect to a data base using PEAR?

Answer: DB::connect(data_source_name);


Which of the following will return 1 if the Memcache session handler is available and 0 if not?



Which bz library function returns bzip2 encoded data after compressing a given string?

Answer: bzcompress()


Which function opens a memcached server persistent connection?

Answer: Memcache::pconnect


On the additional header that PHP allows you to include on an email you can add:

Answer: All of these




MIME version

X-mailer and version number


__________ is the same as setcookie() but the cookie value will not be automatically urlencoded when sent to the browser.

Answer: setrawcookie()


Which function enables automatic compression of large values?

Answer: Memcache::setCompressThreshold


Which of the following will send queries to a database using PEAR?

Answer: none of these







Which PHP library allows you to connect to and communicate with different types of servers using many different types of protocol?

Answer: cURL


Which configuration directive sets the size of data chunks for transfers?

Answer: memcache.chunk_size


What does PEAR stand for?

Answer: PHP Extension and Application Repository


Which of the following functions are used to encrypt passwords?

Answer: md5() and crypt()


Which cURL function sets an option on the given cURL session handle?

Answer: curl_setopt


Which of the following are examples of resource types in cURL?

Answer: cURL handle and a cURL multi handle


Which API treats XML as flow-through string data?

Answer: CAX


What does XML mean?

Answer: eXtensible Markup Language


singleton design pattern

Answer: Sometimes it’s important to have only one instance for a class. For example, in a system there should be only one window manager (or only a file system or only a print spooler). Usually singletons are used for centralized management of internal or external resources and they provide a global point of access to themselves.


PHP magic constant

Answer: __LINE__


When a small window pops up in front of the browser asking your username and a password, what kind of Authentication is being used?

Answer: HTTP


In session management cookies are usually not used for:

Answer: logging the user in for the first time


Which function returns the version of the server?

Answer: Memcache::getVersion


Which character must be set in the $mode argument for fopen($file, $mode) to open a file for reading and writing?

Answer: r+;


Which of the following will open the file “time.txt” as readable?

Answer: fopen(“time.txt”,”r”);


_____________ attempts to establish an FTP connection to a remote server by emulating an FTP client.

Answer: FTP ftp_connect()


Which of the following is the correct syntax to retrieve an object from the memcache module?

Answer: $result = $memcache->get(‘key’);


Which of these will perform integer rather than floating point division?

Answer: intval(x/y)


$count = $count * 3; can be written as:

Answer: $count *= 3;


What is the correct way to add 1 to the $counter variable?

Answer: $counter++;


Which operator appends the argument on the right side to the argument on the left side?

Answer: .=


With the ________ bitwise operator, the bits set in $a are not set, and the not set bits are then set.

Answer: ~


Which bitwise operator will set the bits that are set in either $a or $b.

Answer: ” | “


Which of the following allows you to set a user-defined exception handler function?

Answer: set_exception_handler


In an object method, which of the following is always a reference to the caller object?

Answer: $this


Which kind of reference is used by creating a local variable in a function and a variable in the calling scope referencing the same content?

Answer: Assign by reference.


Which of the following returns the remainder of $a divided by $b?

Answer: $a % $b


What PHP operator is used to access methods and properties of objects?

Answer: ” -> “


Which interface type allows you to chain methods of an object together?

Answer: Fluent Interfaces


Interfaces define a “contract” specifying that an object is capable of implementing a method ____________.

Answer: Specifying exactly how is to be done.


What is the correct way to create a function in PHP?

Answer: function yourFunction()


Which of the following will print “Hi ” followed a name argument passed to the function?

Answer: function sayHi ($name){ print “Hi $name”; }


Include files must have the file extension:

Answer: none of these


What is the term for using a class to create an object?

Answer: Instantiation


PHP constants:

Answer: All of these apply


Can be accessed anywhere in the script regardless of the scope.

Can be used as default argument values.

Cannot change during the execution of the script.

Follow the same rules as labels in PHP.


Which statement can replace several else Statements?

Answer: switch


To retrieve information from a form that is submitted using the “get” method, use ___________.

Answer: $_GET[];


Which POSIX function takes the following two string arguments and an optional third-array argument: A POSIX-style regular expression pattern, and the target string to be matched?

Answer: ereg()


Which PHP operator will attempt to execute its contents as a shell command?

Answer: (` `)


What function takes any number of numerical arguments and returns the largest of the arguments?

Answer: max()


To unregister a session variable STRING use:

Answer: session_unregister(STRING);


Which of the following is correct to select a database in MS SQL?

Answer: mssql_select_db(STRING)


Select the variable used to set the php.ini file to send emails containing the address of the default PHP mail sender.

Answer: sendmail_from


Which configuration directive is used to transparently failover to other servers on errors?

Answer: memcache.allow_failover


Which PHP function is identical to the C fwrite() function?

Answer: fputs()


Which function writes a string to a file?

Answer: file_put_contents


To denote strings in PHP, you can use both double quotes ” ” and which other characters?

Answer: single quotes ‘ ‘


What kind of elements can be contained in constants?

Answer: All of these







Which PHP operator type allows you to execute its contents as a shell command?

Answer: Execution operator


PHP variables start with the following symbol:

Answer: $


Which POSIX function takes a pattern, a target string, and an optional limit on the number of portions to split the string into.

Answer: split


What function raises the first argument to the power of the second argument, with decimal places to be specified by the scale factor?

Answer: bcpow


Instead of a single new line character some clients require which characters?

Answer: “\r\n”


Which function parses input from a file according to a format?

Answer: fscanf


Which file should be edited to set configuration directives?

Answer: php.ini


Which of the following is correct in PHP?

Answer: Zero is interpreted as false


Which parameter of setcookie() defines the amount of time for which a cookie is valid?

Answer: expire


Which control structure allows you to quickly traverse through an array?

Answer: foreach loops


Which types of code can be affected by namespaces?

Answer: Classes, functions and constants.


Although any valid PHP code can be contained within a namespace, only four types of code are affected by namespaces: classes, interfaces, functions and constants.


Which cURL function returns the last error number?

Answer: curl_errno


Which of the following is an invalid constant name?

Answer: 2DAY


Which PHP operator allows you to assign values to variables and arrays?

Answer: “=”


What is the term for breaking the binding between a variable name and variable content?

Answer: Unsetting references.


Which is the operator for the integer remainder from the division of two values?

Answer: %


Which predefined Memcache function turns on data compression?



Which compressed file type can be decompressed without specifying the extension?

Answer: zip


Which configuration directive, in conjunction with memcache.allow_failover, defines how many servers to try when setting and getting data?

Answer: memcache.max_failover_attempts


The correct way to create a numeric variable “v” that might have any real number is:

Answer: $v;


Which of the following databases are supported by PHP?

Answer: All of these



Oracle and Informix

PostgreSQL and Frontbase

mSQL and Interbase


Which of the following is the line to enable in the php.ini file for Windows in order to be able to use DBX?

Answer: extension=php_dbx.dll


Which of the following is the correct way to connect to a mySQL Server?

Answer: mysql_connect(SERVER, USER, PASSWORD);


Which of the following will return variables from a form sent by the HTTP POST method in PHP?

Answer: $_POST


Which version of PHP introduced object oriented programming?

Answer: PHP III


Which of the following will correctly create a constant “const”?

Answer: const const;


What variable is used by session cookies as a user ID?



Functions that represent a behavior of a class are called _________.

Answer: Methods


Which zip function retrieves the compressed size of a directory entry?

Answer: zip_entry_compressedsize


What does cURL stand for?

Answer: Client URL


Which function clears the cache of file status info?

Answer: clearstatcache


Which method defines HTTP Authentication using Apache Server?

Answer: .htaccess files


What is the most widely accepted meaning of the acronym “PHP” today?

Answer: PHP: Hypertext Preprocessor


_______________ defines a cookie to be sent along with the rest of the HTTP headers.

Answer: setcookie()


A special method to perform any activity required to instantiate an object is called a(n) __________.

Answer: Constructor


Which POSIX character matches zero or more instances of the previous regular expression?

Answer: *


Which POSIX character matches any character?

Answer: .


If an exception is not caught, a PHP Fatal Error will be issued with what message?

Answer: “Uncaught Exception …”


Which statement retrieves the value of a function after it is called?

Answer: return


Which “magic” constant implemented inside an include, returns the directory of the included file.

Answer: _DIR_


Which function returns a string containing a byte-stream representation of any value that can be stored in PHP?

Answer: serialize()


How do you write “Hello World 2010” in PHP?

Answer: echo “Hello World 2010”;


Which command returns the filename component of a path?

Answer: string basename ( string $path [, string $suffix ] )


Which file mode will read and write to the end of an existing file or create a new file?

Answer: “a+”


Which server verifies the name password and mail spool location?

Answer: SMTP Server


What does MTA stand for?

Answer: Mail Transfer Agent


The agent used to collect and access the mail spool is called:

Answer: Mail Transfer Agent – not sure


__________ is an extension that provides a way to put entire PHP applications into a single file called PHP Archive for easy distribution and installation.

Answer: phar


Which function is used to connect to a database using Authentication by SQL Database Query?

Answer: @mysql_connect(“localhost”,”databaseuser”,”password”)


Which function takes a single argument and returns the largest integer that is less or equal to that argument?

Answer: floor()


Which function takes a single argument and returns the smallest integer that is greater than or equal to that argument?

Answer: ceil()


What is the expression for returning the square root of 2?

Answer: sqrt(2)


Which Perl Compatible Regex function takes a regex pattern and an array and returns an array of the elements of the input array that matched the pattern?

Answer: preg_grep


Protected members are available to:

Answer: The class itself and the classes that inherit from it


Which of these variables has an illegal name?

Answer: $your-Var


A(n) _____________ is an ordered map that assigns values to keys:

Answer: array


What PHP type represents a series of characters?

Answer: string


Which of the following is NOT a correct way to specify a string?

Answer: alfanum syntax


Strings in PHP can be specified in four different ways: single quoted, double quoted, heredoc syntax and (since PHP 5.3.0) nowdoc syntax


Which of the following allows you to express any real number?

Answer: double


Which of the following is the correct way to create a reference to a global variable?

Answer: $var =& $GLOBALS[“var”];


Which of the following provides a means to access the same content on PHP variables by different names?

Answer: References


Which PHP operator is used to concatenate strings?

Answer: “.”


What PHP token that allows access to static, constant, and overridden properties or methods of a class?

Answer: ::


Which PHP operator type returns the result of string arguments?)

Answer: String operators


Which of these restrictions applies to namespace implementation?

Answer: Nested namespaces are prohibited.


What term applies to an identifier with a namespace separator that begins with a namespace separator, such as \Foo\Bar?

Answer: Fully qualified name.


Which of the following objects lets you create code which specifies which methods a class must implement, without specifying how the objects are handled?

Answer: Interfaces


Which Interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?

Answer: Instantation Design Interface


Which POSIX character matches the beginning of a string only?

Answer: ^


Which of the following are two broad classes of regular expressions that PHP works with?

Answer: POSIX and PHP-compatible regex


Which statement allows you to end a loop?

Answer: break


This “magic” constant refers to the name of the current namespace and it is defined in compile-time



What is the name for instances of a class that contain all the internal data and state information need for the application to run

Answer: Objects


___________ allows a class to be defined as being a member of more than one category of classes

Answer: Polymorphism


The ability to define a class of one kind as being a subtype of a different kind of class is called:

Answer: Inheritance


Which function changes server parameters and status at runtime?

Answer: Memcache::setServerParams


Which function forces a write of all buffered output to the resource pointed to by the file handle?

Answer: fflush


Single-line comments in PHP use the following:

Answer: //


The ability of a class to protect access to its internal member variables is called:

Answer: encapsulation


You can use what function in order to check if a constant is set?

Answer: defined();


Which of these will perform integer rather than floating point division?

Answer: intval(x/y);


______________ is a mechanism for storing data in the remote browser and thus tracking or identifying return users.

Answer: Cookies


Using the Zip Archive Class, which of the following will include a file to a ZIP archive from a given path?

Answer: zipArchive::addFile


Which of the following is an example of predefined cURL constant?

Answer: All of these







Which of the following refers to a set of functions that allows you have access to multiple supported databases without writing your own wrapper functions?

Answer: PHP DBX


Which of the following is the correct syntax to retrieve an object from the memcache module?

Answer: $result = $memcache->get(‘key’);


_____________ attempts to establish an FTP connection to a remote server by emulating an FTP client.

Answer: FTP ftp_connect()


Which of the following will open the file “time.txt” as readable?

Answer: fopen(“time.txt”,”r”);


Which character must be set in the $mode argument for fopen($file, $mode) to open a file for reading and writing?

Answer: r+;


Which of the following is the correct way to implement a “for” control structure?

Answer: for($i=0; $i<10; $i++){ // do something }


Which of the following is the only keyword that can be written before the namespace at the top of the file?

Answer: declare


What is the correct way to access the property of a PHP object?

Answer: $obj->property


Select the convention sign used to indicate private variables and functions:

Answer: _ for $_name


Arrays can be sorted with which of the following functions?

Answer: arsort(), ksort() and uksort();


Private members are accessible to:

Answer: The class itself and the classes that inherit from it


Which function returns the square root of its argument, with number of decimal places set by the optional scale factor?

Answer: bcsqrt()


What 2 types of parsers are used in PHP?



What does MIME stand for?

Answer: Multipurpose Internet Mail Extensions


Which configuration directive defines a comma separated list of server urls to use for session storage?

Answer: session.save_path


Which function gets permissions for the given file?

Answer: fileperms


Which function checks whether a file or directory exists?

Answer: file_exists


PHP constants:

Answer: All of these


Do not have a dollar sign ($) before them.

May be defined and accessed anywhere without regard to variable scoping rules

May not be redefined or undefined once they have been set.

May only evaluate to scalar values.


Which PHP operator type allows evaluation and manipulation of specific bits within an integer?

Answer: Bitwise operators


At compile time static values are bound with

Answer: a name


Which Perl Compatible Regex character will cause any special character to be treated as a simple matching character?

Answer: \


Session files should not be stored on a directory viewable from the Web server because:

Answer: Malicious users may access other users’ login details


Which API reads in an XML file and creates a “walkable” object tree in memory, so it can be used in large documents?

Answer: DOM


What APIs are used for handling XML documents?

Answer: Document Object Model (DOM) and Simple API for XML (SAX)


________________ tests for the end of file on a file pointer.

Answer: feof()


Instantiate an object Demo: require_once(‘class.Demo.php’);

Answer: $objDemo = new Demo();


Which of the following is correct for adding a comment in a PHP script?

Answer: /* comment */


Which function returns (and caches) file permissions level?

Answer: fileperms(file)


Which PHP function sets file modification time or creates a file if it does not exist?

Answer: touch(file, [time])


Which of these PHP file open modes are valid for the specified conditions?

Answer: All of these


The ____________ function can be used in combination with the PHP header() construct to assemble and send file downloads.

Answer: fpassthru


Which function returns (and caches) the time a file was last accessed?

Answer: fileatime(file)


How do you modify the php.ini file to have sessions work correctly on windows?

Answer: change session.save_path = /tmp to session.save_path=C:/temp


Which function gets statistics from all servers in a pool?

Answer: Memcache::getExtendedStats


Which of the following functions returns a Boolean value after attempting to send a message?

Answer: mail()


Which of the following is the correct way to connect to a MySQL database?

Answer: mysql_connect(“localhost”);


Which files should be used to install cURL in an include directory?

Answer: easy.h and curl.h files


Which function returns the largest number that may be returned by rand()?

Answer: getrandmax()


Which Perl Compatible Regex function inserts escape characters into strings that are intended for use as regex patterns.

Answer: preg_quote


Which of the following shifts the bits of $a $b steps to the left?

Answer: $a << $b


What PHP function returns the arctangent in radians of a numerical argument?

Answer: atan()


Which function is used to start tracking a user?

Answer: session_start();


What statement will delete session files?

Answer: session_destroy();


How are sessions tracked on PHP

Answer: With code rewriting using the PHP Session reference variable


Which statement will skip the rest of the current loop iteration and continue execution at the beginning of next iteration.

Answer: continue


Which function returns (and caches) the owner ID number?

Answer: fileowner()


Which of the following is the correct way to implement a do-while loop?

Answer: $j=0; do { print “$j”; } while ($j > 0);


Which of the following is correct to show a message for an exception?

Answer: throw new Exception (“Invalid data”);


What term refers to the ability to shorten Extra_Long_Names improving readability of source code?

Answer: Aliasing


Which operator performs the same function as x=x%y?

Answer: %=


The control error operator is:

Answer: @


Which of the following is the not equal operator?

Answer: !=


Which Perl Compatible Regex function takes a regex pattern as first argument, a string to match against as second argument, and an optional array variable for returned matches?

Answer: preg_grep


What are the levels of visibility possible for a variable or method?

Answer: Public, Private and Protected


Spread the love

Codeigniter Download

Codeigniter 4 has been released and can be used for application development. The new version of code igniter is supported with PHP 7.2 or higher. So Latest release of Code Igniter has all those features that other powerful MVCs framework have.

Code igniter 4 Can be downloaded easily from Code igniter Official Website. Below is the link

Download Codeigniter here :

Read More about Code igniter:

How to start with Codeigniter

What is New In CodeIgniter 4.x?


Spread the love

WordPress After Login Redirect Hook

Want to enhance your WordPress functionality using custom coding, then you are at the right place.  In this article, you are going to learn how to redirect on a custom page after a successful login in WordPress. When you are working on Woocommerce or any other type of application based on WordPress and you need to redirect your logged in user other than the default page or My Account page then you need to add few lines of codes in your functions.php.  Although there are many plugins available for this simple work you can create your own plugin using this successful login redirect code. WordPress is known for its simplicity and flexibility. We will use the feature of filters and hooks to extend the functionality.

Use hook wp_login()

There is wp_login() and we can use this function as a hook to create our own function and to redirect after login.

do_action( 'wp_login', string $user_login, WP_User $user )


Now we can write our own function to modify the default redirection. Suppose we have to redirect on the home page rather than the default page after successful login in WordPress. Then the code in the following example is sufficient :

function my_login_redirect() {
add_action( 'wp_login', 'my_login_redirect', 10, 3 );


Spread the love

Why Laravel Is The Top PHP Framework In 2020-2021

Numerous PHP-frameworks are accessible to use as open-source and free. Be that as it may, at whatever point we talk about Laravel, then the issue is unique. Try not to stress. It is likewise open-source and free PHP structure; however, it came in presence as the top and a propelled contender to the CodeIgniter system.

It is furnished with numerous highlights; for example, worked in help for client authentication and authorization. CodeIgniter missed these highlights. That is the reason the web advancement process utilizing CodeIgniter was very hard.

The expansion of the above highlights expanded the ubiquity and distinction of the Laravel structure. Numerous Laravel development companies engineers as their significant component for creating web applications and believe it is the best and most prestigious PHP structure.

Engineers likewise use Bootstrap Laravel formats while they grow large and complex applications. Numerous different highlights make Laravel the best PHP system in 2020.

We take an itemized conversation on the highlights and rule of the Laravel PHP system in web advancement:

Application structure

About the application structure in Laravel, it accompanies a default application structure. Its application structure is straightforward to use, thus giving high convenience to begin little or huge applications. With this component, designers can modify the application according to the proprietor requests.

Multiple File Storage System

Laravel is in build with various storage systems like cloud, Amazon, and other Exchanging between these profoundly included, and in vogue distributed storage systems will be a not too bad and simple errand because the API utilized for every one of these systems is the equivalent.

A standout amongst other things like this will be the designer will be permitted to use all these three distributed storage systems just in a single application. It will allow engineers to rapidly and effectively serve these files from various areas with no issue.

MVC Architecture Support

Concentrate on straightforwardness is an indispensable factor between business rationale and introduction being developed. Laravel supports MVC. MVC is named as Model View Controller. This design has a full scope of inherent capacities. MVC empowers engineers to support the presentation and offers reasonable documentation advantage.

To get a full favorable position of the Laravel structure, it is recommended to interface with experts having long stretches of understanding and aptitude as they are the individuals offering the total capacity to your web improvement given by Laravel.

Article Oriented Libraries

Laravel accompanies the enormous assortment of Object-Oriented Libraries fused with numerous pre-introduced and worked in libraries like Authentication library. CodeIgniter, Symphony, and other well-known PHP frameworks don’t offer these sorts of Object-Oriented Libraries.

Laravel Authentication Library is outfitted with a wide scope of cutting edge highlights. A portion of different highlights incorporates checking dynamic clients, cross-site insurance and REquest Forgery encryption, Bcrypt hashing, and secret key reset.


Laravel offers restriction benefits that are useful to the engineers in a way to recover strings of a few dialects. Along these lines, the web application will bolster different dialects without any problem. It is beyond the realm of imagination with various frameworks, so it makes Laravel a worldwide marvel.


Pagination is a run of the mill task in web advancement; however, Laravel makes it simpler at the initial step. It causes designers to make clever connections for any site created on the HTML and current page. Moreover, the connections made by designers utilizing pagination in Laravel will perfect with Bootstrap CSS structure.

Sharp edge Template Engine

One of the intriguing realities about Laravel is that it gives an in-manufactured layout motor named Blade. The powerful and smooth Blade templating motor necessarily accompanied Laravel 5.1. Laravel accompanies a first anyway still strong templating engine which isn’t accessible in other PHP frameworks.

It helps engineers from using the understandable code in the views. Also, the cutting edge views then effortlessly take care of into simple PHP code and are before revamped they are stored.

In a couple of conditions, altering or erasing an announcement appears to be an extreme errand while dealing with unpredictable and enormous undertakings. Be that as it may, Blade in Laravel encourages designers to expel or change the announcement with no issue handily.

Steering System

Laravel encourages designers to use a directing framework that is exceptionally helpful and straightforward. They require building up an index for the URI and afterward create and execute appropriate connects to the named courses.

The primary advantage is that while making the code, it puts the URIs depended on connections to the particular links and paths and updates them if the course change.


There are just a couple of frameworks that realize that making authentication is straightforward and quick. Like this, everything has been designed and included as of now for the web engineers for the most part.

The arrangement files comprise every single extraordinary archive that is basic for dealing with the elements of authentication services.

Programming Task Management and arrangement

In each web advancement, the process task the executives and setup is a fundamental factor that ought to be considered by each engineer top to bottom. It is likewise a necessary errand to be done on schedule. It may be sending some other errands or an email, clearing the database, overseeing undertakings efficiently consistently assume a significant job.

Try not to stress the platitude possibly commonplace, yet usage isn’t as Laravel is here with an order scheduler.

While utilizing the order scheduler, just the code passage will be included your server. Corn calls this scheduler over and over.

After the execution of the order, Laravel assesses the booked errand and run all the pending assignments. As such, Laravel offers ease in planning and dealing with the undertakings.


It is challenging to state if any web application is secure and ensured. With the Laravel PHP structure can give the top security to web applications as the passwords will never get spared inside the system as the understandable content. This is the principle reason Laravel uses the hashed secret phrase for security.

Laravel likewise gives the best counteraction to your web applications from infusion assaults. It utilizes SQL articulations to decrease the opportunity for genuine dangers.

Laravel offers numerous security features that include ensuring courses, encryption, HTTP essential authentication, and so forth.

Programmed Package Discovery

Programmed Package Discovery in Laravel discovers which bundles are wanted by clients to introduce. There is no compelling reason to set up any examination.

It is anything but challenging to impair this element, and engineers can do it with no issue. This component is likewise the purpose behind the ubiquity of Laravel.

Spread the love

Code Igniter 4 Release Date

CodeIgniter is an open-source software rapid development web framework, for use in building dynamic web sites with PHP.

Codeigniter is a lightweight MVC architecture based PHP framework.

This is popular for its performance and zero configuration. Codeigniter has beautiful documentation. Since CI is the most flexible PHP MVC framework, people love to work on this.

CodeIgniter is loosely based on the popular model–view–controller (MVC) development pattern. While controller classes are a necessary part of development under CodeIgniter, models and views are optional.

CodeIgniter can be also modified to use the Hierarchical Model View Controller (HMVC) which allows the developers to maintain modular grouping of Controller, Models and View arranged in a sub-directory format.

Till now the biggest release of CodeIgniter is Codeigniter 4.0 or CI 4.0. A final release for the rewritten CodeIgniter 4.0 is live.

The first public version of CodeIgniter was released by EllisLab on February 28, 2006.

Developers all over the world were waiting for its release and on 24 Feb 2020, It was released.

Waiting time is over now the alpha is released by Code Igniter officials finally, last month.

The first stable version of CI 4 is CodeIgniter 4.0.0.

Key Features of Code Igniter 4.x:

  • High Performance MVC framework
  • Minimal Configuration as the earlier versions
  • HMVC Structure
  • Based on PHP 7.2 and ahead
  • An MVC framework with a small footprint
  • Highly secured and inbuilt CSRF protection for HTTP requests

Server Requirements for Code Igniter 4.x

PHP version 7.2 or higher is required, with the following extensions installed:

  • intl
  • libcurl if you plan to use the HTTP\CURLRequest library

Additionally, make sure that the following extensions are enabled in your PHP:

  • json (enabled by default – don’t turn it off)
  • xml (enabled by default – don’t turn it off)
  • mbstring
  • mysqlnd
Spread the love

PHP Send Emails

In this article, you will find the answer to the question “How to use PHP mail() function and how to send emails using PHP?

The mail() Function in PHP

Email is an important part of communication and frequently used by web applications to notify users about important events and actions.

When we register with some application we get an instant notification as Welcome Email.

Almost every website has a contact us page and there is a form with some fields.

Users use this form to communicate with customer care or for any inquiry or to get any Quotations.

We can use the PHP built-in mail() function for sending email messages to many recipients using PHP application.

We can send Plain text messages or HTML rich text messages with styled and multicolor design. In PHP mail() function is used as following:

mail(to, subject, message, headers, parameters);

The PHP mail() function has the following parameters:

Mandatory Parameters:
to: This email address of the recipient.
subject: Subject of the email to be sent.
message: This is the message body and main content of the email.

Optional Parameters:
headers: This is used to add headers such as “From”, “Cc”, “Bcc”.
parameters: This is used to add additional parameters.

Simple Mail Transmission Protocol (SMTP) Configuration:

PHP mailer uses the Simple Mail Transmission Protocol (SMTP) to send mail.
The SMTP settings would have already been configured.
The SMTP mail settings can be configured from “php.ini” file in the PHP installation folder.

Sending Plain Text Emails using mail() Function with Example:

We can send simple text messages using PHP mail() function. An example is given below:

Sending HTML Emails using mail() Function with Example:

We can send rich text styled HTML messages using PHP mail() function. An example is given below:

Spread the love

PHP Full Form

What is the Full Form of PHP?

PHP means Hypertext Preprocessor.

At the starting PHP was Personal Home Page, but later it is amended and popular as Hypertext Preprocessor.
As a server-side scripting language PHP can be easily embedded into HTML pages. PHP has a rich library and now it is improved as a full-fledged programming language. The latest stable version of PHP is PHP 7.2.

You can read more about New Features in PHP 7.2 here.

PHP is useful for small scale to many complex solutions as there is a number of frameworks, SMSs, and ECommerce are available.

Salient Features of PHP are as follows:

  • Server-side scripting language
  • Lightweight Programming language
  • Open-source
  • Supported by all the platforms
  • Written in C, so performance is good
  • Object-Oriented Programming Language
  • Supports many RDBMS like MySQL, PostgreSQL,Oracle,Sybase,Solid and NoSQL like MongoDB.
  • PHP provides a multilayer structure to enable security in System.


PHP along with MySQL is a beautiful combination of server-side scripting language and Open Source RDBMS. MySQL is largely used SQL based RDBMS. PHP has a library that supports MySQL functionality to call from PHP code. We can retrieve data, insert data. My SQL also supports Transaction in Database.

LAMP Server

LAMP is for Linux Apache MySQL and PHP. This is a combination of all the server needs and Database need to run a PHP application on Linux System. We can install LAMP on our Linux machine as a combination of all these four technologies.

WAMP Server

Just like LAMP, we have WAMP for Windows machine. WAMP means Windows, Apache, MySQL, and PHP. This combination provides us the accessibility and environment to run PHP and MySQL based application in a Windows machine.

Spread the love

PHP Code Online

PHP is a server-side scripting language used by millions of users worldwide. Full-Form of PHP is HyperText PreProgramming. The secret behind the popularity of PHP is simplicity and being Open Source. PHP has the biggest community over the world to support and share.

PHP has numerous Frameworks and CMS along with eCommerce that make it considerable. Developers need to write and debug some piece of code regularly and without saving them in a file and then run by the server in a local machine or on the server.

There are many such places available where we can run our chunk of PHP Code or a complete PHP Program and without saving it in any file.

These websites provide online PHP editor to write code and to execute PHP Code online. These are the Online Compiler and Interpreter providers helping the coders.

You just need to type your code and click on the run button without any mess and you will get the output of the program.

There are numbers of Online PHP editor where we can run or PHP Code and PHP Program:

Write Php Online

This is the best place where you can use PHP editor and can run your PHP code and PHP Program Online. You will find a very simple interface and a white background code editor to write PHP Code. You don’t need to save your PHP Program. There is a run button just below the PHP Editor once you will finish your PHP Code just click run and you will have your output. It is a very quick interpreter and loved by almost the PHP Developers.


Online PHP IDE

Joodle is the IDE provider. It provides the API to embedded IDE for almost the programming languages in any HTML page. You can use its interface to write PHP Code and get instant output. This PHP Editor is featured with Full Screen Editing Mode, User Input Console, Memory and Time analytics of the program.


Geeks For Geeks IDE

This is one where you can save your code for a longer time. This saves your content in your storage or in the browser. Whenever you will be back you will find your last PHP programs. This PHP Editor Provides tabs for many other programming languages you can just click and switch between the languages. GFG IDE provides two modes of the editor – Dark Mode or Night Mode and Light Mode.


This is a separate subdomain of Geeks Fo Geeks dedicated to IDEs for different languages.

PHP Tester

PHP Tester is a dedicated IDE for PHP and lets you write PHP Code and Run PHP code online. This provides you the facility to test your PHP code and get instant Result Online. You can also switch between the versions of PHP in this PHP Editor. You can easily check where a code is compatible with different types of PHP versions or not.


Interview Sort out

Interview Sortout also provides you a PHP Editor and Interpreter powered by Joodle. We have used a dark PHP Editor theme, that is loved by almost the programmers. You can run your PHP programs here without any server and without saving it to any file. This tool provides you with highlighted syntax and output with time and memory usage.


Spread the love

Joomla Interview Questions

Joomla Interview Questions for beginners and professionals with a list of top frequently asked Joomla interview questions and answers. This special piece of content is designed for people who are looking for a job as a Joomla developer.

This will be helpful to clear Joomla Interview. Here is the list of basic and conceptual Joomla Interview Questions and Answers:

What is Joomla?
Joomla is an open-source Content Management System (CMS), it allows users to develop online applications, e-commerce, blog sites, and websites. Joomla is built on a model view controller (MVC) architecture.

What is the position in Joomla?
Joomla site template divides the page into a various number of positions like nav, header, footer, top, bottom, module, etc.  This is nothing but a position. You can create as many positions in a template as you want, there is no restriction for it.

Explain what Joomla Modules are?
Modules are small content items that can be displayed anywhere in websites by assigning positions in the template. We can add multiple modules on a page at different positions.

What are the components in Joomla?
Components are responsible for the main content part in a template that makes changes on every click of the menu and displays the main functionality of the site. These are the core elements of Joomla!’s functionality. They include Content, Banners, Contact, News Feeds, Polls and Web Links.

By default what is the prefix Joomla has?
Joomla has a prefix like jos_, but during installation, you can set it according to you by default it generates a random prefix.

In Joomla CMS what is the file where database settings are stored?
Database settings are stored in the root directory under configuration.php.

How many files are required to build a module in Joomla?
Two files are required to build a fundamental module in Joomla:

  1. Mod_module_name.php
  2. mod_module_name.xml


What are the advantages of using Joomla?
Main advantages of using Joomla can be listed as:

  1. Joomla is open-source and free to use.
  2. It provides a lot of free components that are available in
  3. It has inbuilt permission and user role.
  4. One-click update.
  5. Provide simple, elegant and user-friendly templates free to use.
  6. Secure and user-friendly Interface for CMS.
  7. It can be used for eCommerce.
  8. Joomla generates SEO friendly URLs.
  9. Joomla is an MVC framework as well as CMS.


What are the limitations of Joomla?

  • Provide limited options
  • Plugin compatibility may cause an issue.
  • Its websites are heavy
  • Limited server resources and efficiency


Is Joomla a Blogging tool only?
Joomla can be used as a blog, but it is more powerful and rich in features compared to full blog systems like WordPress. Joomla should be preferred when your requirements are more than just blogging

By default how many tables Joomla have?
A fresh installation of Joomla can have 78 tables.

How many Joomla tables are related to users?
Table related to users in Joomla are :

  1. Jos_users
  2. Jos_usergroups
  3. jos_user_usergroup_map


How can you make a menu link that is not clickable?
You can use a link type separator/placeholder to create a menu link that is not clickable 

(doesn’t connect to anything or not to assign any component to it).

What meta description in Joomla Menu Manager?
Meta Description is basically used for SEO Purpose. It is a short description of the content and optional paragraph which is displayed in the results of search engines.

Name the editor used by Joomla content editor?
Joomla content editor uses TinyMCE Editor.

What Is The Default Super Administrator Account For Joomla Called?

What is Mambot in Joomla?
A Mambot is a small, task-oriented function, mini-program or plugin. It is used to modify content before display, extend site search, add core functionality, etc. Mambots are renamed plugins in Joomla 1.5.

What is Joomla Plugins?
Plugins are a kind of Joomla extension in Joomla. A Plugin is very flexible and powerful for extending the framework functionality. It contains a bit of code that is used to execute the particular display output of a component or module when the page is built. The plugin functions which are associated with the event are executed in a sequence when a particular event occurs.

How To Link Inside Content And Another Content Item?
Get the URL for the particular page you want to link this to. Create a link using a specific editor or with HTML, if you have no WYSIWYG.

Spread the love

What is New in PHP 7

PHP 7 is introduced as the next version of PHP.

The earlier one is PHP 5.6. The latest version is scalable and more flexible, faster and easy to implement complex logic.

Many new features are introduced with PHP 7.

These features are equally useful for the interview aspirants. Few of them are explained :

PHP 7 Features

  • Scalar type declarations
  • Return type declarations
  • Null coalescing operator
  • Spaceship operator
  • Constant arrays using define()
  • Anonymous classes
  • Unicode codepoint escape syntax
  • Closure::call()
  • Group use declarations

Scalar type declarations

There may be two scalar types of declarations :

  • coercive(default)
  • strict

We can enforce the types for parameters either coercively or strictly are :

  • strings (string)
  • integers (int)
  • floating-point numbers (float)
  • booleans (bool)

For Example in Coercive mode:

	function addTheNumbers(int ...$ints)
	    return array_sum($ints);
	var_dump(addTheNumbers(3, '7', 7.8));

Declaration of Return Type

PHP 7 started support for return type while declaring a function.
The return type declarations specify the type of value that will be returned after execution.

For example :

function sumOfArrays(array ...$arrays): array
    return array_map(function(array $array): int {
        return array_sum($array);
    }, $arrays);

print_r(sumOfArrays([10,20,30], [14,15,16], [17,18,19]));

In the above function, the accepted argument are arrays and the return type of the function is also an array.

Null coalescing operator

This is a comparison and validation operator added to PHP 7 and It is used as a ternary in conjunction with isset() function.
If the expression exists and not NULL then it returns the first operator else it returns the second one.

For example :

	$booktitle = $_GET['title'] ?? 'no_books';

If the title is set in $_GET and the value of the $_GET[‘title’] is NOT NULL then the value of $booktitle will be the $_GET[‘title’]. In a condition of failure the title will be ‘no_books’.

Spaceship operator

This is a pure comparison operator and compares the values of two variables. It returns -1, 0 and 1. It compares less than, equal to and greater than.

Have a look at examples :

// Integers
echo 7 <=> 7; // 0
echo 7 <=> 8; // -1
echo 8 <=> 7; // 1

// Floats
echo 7.5 <=> 7.5; // 0
echo 7.5 <=> 8.5; // -1
echo 8.5 <=> 7.5; // 1

// Strings
echo "b" <=> "b"; // 0
echo "b" <=> "c"; // -1
echo "c" <=> "b"; // 1

Constant arrays using define()

In PHP 7 we can define an array as a constant, like strings and numbers. It can be done using the define() function.

define('SUPER_HEROS', [
    'Iron Man',
    'Captain America',
    'Spidar Man'

echo SUPER_HEROS[1]; // outputs "Thor"

Anonymous classes

PHP 7 has introduced support for Anonymous classes. Anonymous classes can be used in place of the full class definition for throwaway objects.

interface Logger {
    public function log(string $msg);

class Application {
    private $logger;

    public function getLogger(): Logger {
         return $this->logger;

    public function setLogger(Logger $logger) {
         $this->logger = $logger;

$app = new Application;
$app->setLogger(new class implements Logger {
    public function log(string $msg) {
        echo $msg;


Unicode codepoint escape syntax

A valid Unicode codepoint character can be converted to UTF-8 corresponding character. All the leading 0’s will be neglected.

	echo "\u{aa}";
	echo "\u{0000aa}";
	echo "\u{9999}";

The above example will output:

ª (same as before but with optional leading 0’s)


Closure::call() is a way of temporarily binding an object scope to a closure.

<?php class MyClass { private $val = 1; } $getVal = function() {return $this->val;}; 
echo $getVal->call(new MyClass);

Group use declarations

Classes, functions, and constants being imported from the same namespace can now be grouped together in a single-use statement.

	use some\namespace\{ClassA, ClassB, ClassC as C};
	use function some\namespace\{fn_a, fn_b, fn_c};
	use const some\namespace\{ConstA, ConstB, ConstC};

Here we don’t need to import one by one, we can import all the classes in a single call. Similarly the functions and constants also.

Now we are able to understand the new updates in PHP 7. Hope this will help. Happy Learning 🙂

Spread the love

In How many ways we can use Model in CakePHP

CakePHP is an MVC based framework and facilitates unlimited flexibility. A model in cake PHP is used for the data source and all the logics that require to gather the data.

Later we use a Model functions to get these formatted data in Controllers and send them to view using the set function.

Here we are going to learn in how many ways we can use a Model or data source in CakePHP applications.

The naming convention followed in CakePHP help us to reduce our effort and to make the development process rapid.

Since Model is used as a logical unit and data source we can use it in any Controller where we need the data, irrespective the name of model and controllers.

A Controller with name “Users” can access the functions written in Model User without any manual initialization. But the question is how to use another Model and its functions in Users Controller?

When we are developing a complex application we usually need to access data from many tables or we can say from many Models in a single controller.

If there is no association then we need to initialize the other Models manually. Once we initialize these models we can use any functions in these models in the Controller. We can use any data source in any controller.

Even we can use the Model in our plugins Model, in the same way, we use in our standard models.

There are different ways to initialize a model in any Controller:

  • Initialize at the start of Controller and use it in any action of Controller.
  • Initialize in the particular action of Controller.
  • Initialize and Using in Another model.

Initialize at the start of Controller and use it in any action of Controller

There are many such situations when we need to use any model continuously in all the functions, then we need to initialize a model that can be used from anywhere.

Here we once initialize the model is available anywhere in a controller to use. We should not use this method when we are using the Model in only a few functions.

This may create overhead to the application when each time a data source is being loaded without reason.

Initialize in a particular action of Controller

When we have limited usage in a controller then it is not a good practice to initialize a model at the start.

We should initialize when we need only.

There may be some particular function that needs to access data from another model.

Initialize and Using in Another model

There are many such situations arrived when you need to use another model functions in your model, then you need to import that model in your model.

When we need additional data apart from association we need to fetch data from a model that is not the current model. CakePHP provides flexibility to use a number of existing model functions in your model.

This facilitates code reusability and improves the maintainability of application and at the same time reduce overhead and development time.

Hope this article will help you in using a model in Cake PHP in different ways.

Happy Learning 🙂

Spread the love

How to add additional fields to user profile in WordPress

WordPress is the most-popular CMS and provides unlimited flexibility to users to do anything they wish.

To maintain its flexibility and maintainability WordPress provides hooks. Using these hooks we can extend the functionality and customize the interfaces as per requirement.

WordPress provides metadata to add additional information with content.

Using these meta we can add number of custom fields with any content like post, page,media,user,category,terms etc.

Here we would know that how to add an additional field to user profile?
For example we have to add highest educational qualification of users.

So we need to to add a user meta for this field. Let the field name is highest_qualification.

We will hook the user meta to the hooks related to user profile. Available hooks for user profile are:

  1. show_user_profile
  2. edit_user_profile
  3. personal_options_update
  4. edit_user_profile_update

These hooks enable user to add and update the meta field. Lets have a look on code snippets:
STEP #1: Add form field when user is going to edit the profile details:

Create a function add_user_educational_qualification and hook it with show_user_profile and edit_user_profile.

    add_action( 'show_user_profile', 'add_user_educational_qualification' );
    add_action( 'edit_user_profile', 'add_user_educational_qualification' );
    function add_user_educational_qualification( $user ) { ?>
    <table class="form-table">
       <label for="address"><?php _e("Highest Educational Qualification");?></label>
      <input type="text" name="highest_qualification" id="highest_qualification" value="<?php echo esc_attr( get_the_author_meta( 'highest_qualification', $user->ID ) ); ?>" class="regular-text" />
     <span class="description"><?php _e("Please enter your heighest Educational Qualification."); ?></span>
<?php }  ?>

STEP #2 : Now we need to save this information to user_meta table , so we need the hook that are used to save or update the user profile and details.

Create a function save_user_educational_qualification and hook it with personal_options_update and edit_user_profile_update.

	add_action( 'personal_options_update', 'save_user_educational_qualification' );
	add_action( 'edit_user_profile_update', 'save_user_educational_qualification' );

	function save_user_educational_qualification( $user_id ) {
	    if ( !current_user_can( 'edit_user', $user_id ) ) { 
	        return false; 
	    update_user_meta( $user_id, 'highest_qualification', $_POST['highest_qualification'] );

STEP #3: Now we need to display this information any where in the website:

We are ready with our additional field highest_qualification. We have added it and saved it to database.

WordPress provide a function highest_qualification and using this function we can get the value of meta fields.


   $meta_key = 'highest_qualification'; 
   $highest_qualification = get_user_meta( $user_id, $meta_key,true); 
Spread the love

PHP Advanced Interview Questions and Answers For Experienced

We brought here some advanced PHP interview questions that need special attention while preparing for an Interview.

We have collected these questions and answers from various sources and candidates have been appeared in multiple PHP Developer Interviews.

These questions are useful for Freshers searching jobs for PHP developers and also for the people looking for a change having 2+ years experience.

Find the latest PHP MySQL interview questions and answers for experienced in 2020.

These are not pure practical based questions but they have a huge impact on your selection for the right job.

How we can set default time-zone in PHP?
Using library function date_default_timezone_set() we can set default time-zone:

<?php date_default_timezone_set("America/New_York"); echo "Time in Default Zone is : " . date("h:i:sa"); ?>

What is difference between == and === ?
Both are the comparison operator. The first one (==) is ‘Equal to’ and the second one (===) is ‘identical to’. ‘Equal to’ is used to compare the values of variables. ‘Identical to’ is used to compare values as well as the type of variables.

For Example :

<?php $x = 1250; $y = '1250'; if($x==$y){ echo 'X and Y are Equal'; }else{ echo 'X and Y are Not equal'; } if($x===$y){ echo 'X and Y are Identical'; }else{ echo 'X and Y are Not Identical'; } ?>

What is difference between != and !== ?
Both are the comparison operator. The first one (!=) is ‘Not Equal’ and second one (!==) is ‘Not identical’. ‘Not equal’ is used to compare the values of variables. ‘Not Identical’ is used to compare values as well as the type of variables.

For Example :

<?php $x = 1250; $y = '1250'; if($x!=$y){ echo 'X and Y are Not equal'; }else{ echo 'X and Y are Equal'; } if($x!==$y){ echo 'X and Y are Not Identical'; }else{ echo 'X and Y are Identical'; } ?>

How do I get PHP Errors to display?
Use the following code snippet to on error reporting in a PHP script:

	ini_set('display_errors', 1);
	ini_set('display_startup_errors', 1);

But we can not display PHP parse error this way. We need to modify php.ini file and need to ‘on’ the display error:

display_errors = on

What is the difference between Notice Errors and Warning Errors in PHP?
Notice and Warning are the Non-fatal Errors and Not let the script halted.
Notice is an Advisory message regarding what you should prefer to do with this line of code.
For example, using an undefined variable is a Notice.




The warning is the message saying that you are going wrong and that may cause an error in the future so, you may correct that. For example, including a not existing script will throw a Warning.



What is the use of break and continue in the PHP loop?
Break: It terminates the loop and exit from the iteration.

Continue: It escapes the current iteration and starts a new iteration in the loop.

What are the common types of errors that occur in Php execution?

Php has Identified numbers of Error detection categories. Following are the common errors in PHP:

E_ERROR: A fatal error and halts the script from further execution.

E_WARNING: Run time warning that detects something is wrong that you need to correct to avoid future errors.

E_PARSE: Compilation error when the code is parsed. We need to on the error reporting in php.ini file to get this.

E_NOTICE: Run time notice to notify that you should go follow the suggested message.

E_CORE_ERROR: It is a fatal error that halts the script and occurs at the initial startup of PHP.

E_CORE_WARNING: Warnings that occurs at the initial startup of PHP.

E_COMPILE_ERROR: Fatal error on compilation occurs at the initial startup of PHP.

E_USER_ERROR : User-generated error message.

E_USER_WARNING: User-generated warning message.

E_USER_NOTICE: User-generated notice message.

E_STRICT: Run-time notices.

E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error

E_ALL: Catches all errors and warnings

Difference between mysql_connect and mysql_pconnect?
When mysql_pconnect() is used to create and maintain a persistent connection to the database that means a SQL link that does not close when the execution of your script ends whereas mysql_connect() creates a new connection each time when it called.

When a persistent connection is created and again a connection request is called the mysql_pconnect() return the earlier established connection rather than creating a new instance of connection.

What do you understand by &$name?
Using the reference of the variable rather than a copy of that.

If we pass the reference of a variable in a function as an argument and the value is changed then the value of the original variable outside the function is also changed.

This is passing by reference.

What is New in PHP 7?
PHP 7 has many new features. Here is the list of PHP 7 New features:

  • Scalar type declarations
  • Return type declarations
  • Null coalescing operator
  • Spaceship operator
  • Constant arrays using define()
  • Anonymous classes
  • Unicode codepoint escape syntax
  • Closure::call()
  • Group use declarations

When you are going for a PHP Developer job you should also focus on Jquery Interview Questions, PHP-MySQL Interview Questions, PHP Functions asked in Interviews.
I hope you enjoyed learning. You can ask any question based on the Above topic or you can submit questions here in the comment box.

Spread the love

CakePHP 4.0.0 alpha is released

The new and most awaited version of the rapid development framework is released by the core team of CakePHP.

The alpha released yet is not recommended for development purpose, until the stable version come. Removing the drawbacks and implementing new features , library support and improved performance the new version of cakephp will be rocking soon.

What are the new features in CakePHP 4.0.0

The Directory structure and the Bake console is rewritten to ease the development process and to increase development speed.

CakePHP was using Foundation framework for CSS and UI , but they are going to discontinue this associations and will go with the new one i.e. milligram.

Automatic Time zone handling by the ORM if any difference is found between Database timezone and server timezone.

All the deprecated features will be removed completely in new version.

CakePHP will not support PHP 5.6 and PHP 7.0, The minimum version that will be acceptable is PHP 7.1.0. Further It will be modified to PHP 7.2.0 as a minimum acceptable version of PHP.

An improved type-hinting will be added.

Error and warning reporting system is improved.

Validation messages will be embedded in Form helper and date-time input is introduced.

Authentication functionality has been split into standalone plugins Authentication and Authorization.

Spread the love