Ans: PHP is a server-side scripting language. It is the most widely used web technology to create dynamic web pages. There are many PHP based frameworks and Open sources available for free to use. Some examples include WordPress, Drupal, Laravel, etc. We can embed PHP with HTML and can further write server-side code with PHP for web development.
Q2. Which is the latest version of PHP?
Ans: Stable release: 7.1.4 / 13 Apr 2017; http://php.net/downloads.php
Ans: .php, .phtml, .php3, .php4, .php5, .php7, .phps .
Ans: The include() statement includes and evaluates a specified line i.e. it will include a file based in the given path. require() does the same thing except upon failure it will generate a fatal error and halt the script whereas include() will just give a warning and allow the script to continue. require_once() will check if the file already has been included and if so it will not include the file again.
Ans: GET and POST are used to send information from client browser to web server. In case of GET, the information is sent via the GET method in name/value pair and is URL encoded. The default GET has a limit of 512 characters. The POST method transfers the information via HTTP Headers. The POST method does not have any restriction in data size to be sent. POST is used for sending data securely and ASCII and binary type’s data. The $_REQUEST contains the content of both $_GET, $_POST and $_COOKIE.
Ans:
1. Open website http://www.tutorialmines.net
2. Request sent to a server of http://www.tutorialmines.net
3. Call PHP Files.
4. PHP Scripts are loaded into memory and compiled into Zend opcode.
5. These opcodes are executed and the HTML generated.
6. The same HTML is sent back to Browser.
Ans: The session is a superglobal variable that preserves data across subsequent pages. Session uniquely defines each user with a session ID, so it helps to make a customized web application where user tracking is needed.
Ans: A cookie is a small piece of information stored in a client browser. It is a technique used to identify a user using the information stored in their browser (if already visited that website). Using PHP we can both set and get COOKIE.
Ans: For finding the length of the string we use strlen() function and for an array, we use count() function.
Ans: These are PHP mechanisms for code re-usability to ease developers for using the code in different class hierarchies.
Ans:
Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
Ans: We cannot change the value of a constant.
Ans: unset() is used to destroy a variable whereas unlink() is used to destroy a file.
Ans: Get current date and time
<?php echo date ( 'Y-m-d H:i:s' ) ; ?>
|
password_hash
and password_verify
which are respectively used as a hashing and checking method. MD5 was used before but now has become obsolete.
Ans: Both are used to split a string to an array, the basic difference is that split() uses a pattern for splitting and explode()uses a string. explode() is faster than split() as it does not match the string based on a regular expression. Also, split() is deprecated as of 5.3.0. So using this function is discouraged.
Ans: The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. It is a data-access abstraction layer, so no matter what database we use the function to issue queries and fetch data will be same. Using PDO drivers we can connect to the database like DB2, Oracle, PostgreSQL, etc.
printf()- Displays a formatted string
sprintf()-Saves a formatted string in a variable
fprintf() -Prints a formatted string to a file
number_format()-Formats numbers as strings
Ans: Javascript is a client-side scripting language whereas PHP is a server-side scripting language.
Ans: The simplest way is to use $_SERVER["REMOTE_ADDR"];
but there are many variables like proxies, server, client, system, current, and public that may require specific changes.
Ans: CONSTRUCTOR: PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.
DESTRUCTORS: PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence
Ans: The difference between an ID and Class is that an ID can be used to identify one element, whereas a class can be used to identify more than one.
Ans: We will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.
Ans: <?php
session_start
echo session_id;
?>
Ans: Destroy a session
PHP:
<?php
session_start;
session_destroy;
?>
Ans: Associative arrays are arrays that use named keys that you assign to them.
Ans: Suppose we want to show and hide elements of a div with id div1.
Ans: Suppose we want to change the font size of and div with id div1 from 12px to 18px.
Change font size using jquery
JavaScript:
}
?>
Ans: The superglobal variables as follows:
Ans: It is a stable, reliable and powerful solution with advanced features like the following: