What are magic functions or methods in php?
The function names __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(),__unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state() and __clone() are magical in PHP classes. You cannot have functions with these names in any of your classes unless you want the magic functionality associated with them.
__sleep() and __wakeup()
serialize() checks if your class has a function with the magic name __sleep(). If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. If the method doesn’t return anything then NULL is serialized and E_NOTICE is issued.
The intended use of __sleep() is to commit pending data or perform similar cleanup tasks. Also, the function is useful if you have very large objects which do not need to be saved completely.
The intended use of __wakeup() is to reestablish any database connections that may have been lost during serialization and perform other reinitialization tasks.
Differentiate the LIKE and REGEXP operators?
SELECT * FROM pet WHERE name REGEXP “^b”;
SELECT * FROM pet WHERE name LIKE “%b”;
What are the String types are available for a column?
The string types are CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET.
An ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time.
An enumeration value must be a quoted string literal; it may not be an expression, even one that evaluates to a string value. For example, you can create a table with an ENUM column like this:
CREATE TABLE sizes ( name ENUM('small', 'medium', 'large') );
What is the difference between CHAR AND VARCHAR?
The CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved.
The length of a CHAR column is fixed to the length that you declare when you create the table.
The length can be any value between 1 and 255. When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed.
How quoting and escaping work in SELECT QUERY?
SELECT ‘hello’, ‘hello’,‘hello’, ‘hel‘‘lo’, ‘\‘hello’.
What is the difference between BLOB AND TEXT?
A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB differ only in the maximum length of the values they can hold.
What are the different types of errors in php?
E_ERROR: A fatal error that causes script termination
E_WARNING: Run-time warning that does not cause script termination
E_ALL: Catches all errors and warnings
E_PARSE: Compile time parse error.
E_NOTICE: Run time notice caused due to error in code
E_USER_WARNING: User-generated warning message.
E_USER_ERROR: User-generated error message.
E_USER_NOTICE: User-generated notice message.
E_STRICT: Run-time notices.
E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
What is maximum size of a database in mysql?
Depend on Operating System
how many ways we can retrieve the data in the result set of MySQL using PHP?
You can do it by 4 Ways
What is the difference between mysql_fetch_object and mysql_fetch_array?
mysql_fetch_object() is similar tomysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).
How can we extract string ‘abc.com ‘ from a string ‘http://firstname.lastname@example.org’
using regular expression of PHP?
How can we create a database using PHP and MySQL?
We can create MySQL database with the use of
What are the differences between require and include, include_once and require_once?
The include() statement includes and evaluates the specified file.The documentation below also applies to require(). The two constructs are identical in every way except how they handlefailure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missingfile to halt processing of the page.
include() does not behave this way, the script will continue regardless.
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only differencebeing that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once() should be used in cases where the same file might be included and evaluated more than once during a particularexecution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
require_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?
Yes we can use include() more than one time in any page though it is not a very good practice.
How can we encrypt the username and password using PHP?
The functions in this section perform encryption and decryption, and compression and uncompression:
DES_ENCRYPT() DES_DECRYPT() ENCRYPT() Not available MD5() Not available OLD_PASSWORD() Not available PASSWORD() Not available SHA() or SHA1() Not available Not available UNCOMPRESSED_LENGTH()
What is meant by nl2br()?
Inserts HTML line breaks (<BR />) before all newlines in a string.
What is htaccess? Why do we use this and Where?
.htaccess files are configuration files of Apache Server which provide
a way to make configuration changes on a per-directory basis. A file,
containing one or more configuration directives, is placed in a particular
document directory, and the directives apply to that directory, and all
What are the features and advantages of object-oriented
One of the main advantages of OO programming is its ease of
modification; objects can easily be modified and added to a system there
by reducing maintenance costs. OO programming is also considered to be
better at modeling the real world than is procedural programming. It
allows for more complicated and flexible interactions. OO systems are
also easier for non-technical personnel to understand and easier for
them to participate in the maintenance and enhancement of a system
because it appeals to natural human cognition patterns.
For some systems, an OO approach can speed development time since many
objects are standard across systems and can be reused. Components that
manage dates, shipping, shopping carts, etc. can be purchased and easily
modified for a specific system
What is meant by MIME?
Multipurpose Internet Mail Extensions.
WWW ability to recognise and handle files of different types is largely dependent on the use of the MIME (Multipurpose Internet Mail Extensions) standard. The standard provides for a system of registration of file types with information about the applications needed to process them. This information is incorporated into Web server and browser software, and enables the automatic recognition and display of registered file types.
What is meant by PEAR in php?
PEAR is short for "PHP Extension and Application Repository" and is pronounced just like the fruit. The purpose of PEAR is to provide:
A structured library of open-sourced code for PHP users
A system for code distribution and package maintenance
A standard style for code written in PHP
The PHP Foundation Classes (PFC),
The PHP Extension Community Library (PECL),
A web site, mailing lists and download mirrors to support the PHP/PEAR community
PEAR is a community-driven project with the PEAR Group as the governing body. The project has been founded by Stig S. Bakken in 1999 and quite a lot of people have joined the project since then.
What is maximum size of a database in mysql?
Depend on Operating System