New Assignment for Bootstrap

1.Who is Father of PHP?
The father of PHP is Rasmus Lerdorf.
2.what is PHP?
PHP is a web language based on scripts that allows developers to dynamically create generated web
3.What is the difference between $name and $$name?
the $$ represents a variable variable. Here’s how they work
$foo = ‘bar’;
$name = ‘foo’;
echo $name; // foo
echo $$name; //bar
echo $foo; //bar
You first assign the value of a variable, $name, to the name of another variable. When you set $name
to a value, it will replace that variablename with the value of the variable you provide it.
$test = ‘asdf’;
$$test = ‘I am changing asdf\’s value!’;
echo $$test; // I am changing asdf’s value!
echo $test; // asdf
echo $asdf; // I am changing asdf’s value!
4.what is the difference between include and require functions.
require will throw a PHP Fatal Error if the file cannot be loaded. (Execution stops)
include produces a Warning if the file cannot be loaded. (Execution continues)
5.can we use include(“xyz.php”) two times in a PHP page “index.php”?

Yes,we can use include(“xyz.php”) more than one time in any page but it

create a problem when xyz.php file can contain some function declaration

then error will come for already declared function in this file else not a prob

like if you want to show same content two times in page then must include it

two times not a problem.

6.Which programming language does PHP resemble to?

PHP syntax resembles Perl and C

7. What does PEAR stands for?

PEAR means “PHP Extension and Application Repository”. it extends PHP and provides a higher level of

programming for web developers.

8.How do you execute a PHP script from the command line?

ust use the PHP command line interface (CLI) and specify the file name of the script to be executed as


1.use cmd

2.go to the file located path

3.then give php filename.php

9.How to run the interactive PHP shell from the command line interface? command promt

2.c:\xampp\php>php –a

Interactive mode enabled

//write any script here

Ctrl+z (press it)


10.What is the main difference between PHP 4 and PHP 5?

Difference between php4 and php5

PHP5 introduces many new features, I have mentioned some of them:

Unified Constructors and Destructors:

In PHP4, constructors had same name as the class name. In PHP5, you have to name

your constructors as __construct () and destructors as __destruct ().


In PHP5 you can declare a class as Abstract.

Startic Methods and properties:

Static methods and properties are also available. When you declare a class member as

static, then you can access members using :: operator without creating an instance of



PHP5 introduces a special function called __autoload()


PHP5 allows you to declare a class or method as Final

Magic Methods

PHP5 introduces a number of magic methods.

__call, __get, __set and __toString


In PHP5, There are 3 levels of visibilities:

Public: Methods are accessible to everyone including objects outside the classes.

Private: only available to the class itself.

Protected: accessible to the class itself and inherited class.


PHP5 has introduced ‘exceptions’(exception errors)

Passed by reference

In PHP4, everything was passed by value, including objects. Whereas in PHP5, all

objects are passed by reference.


PHP5 introduces interfaces . An interface defines the methods a class must implement.

All the methods defined in an interface must be public.

E_STRICT Error Level

PHP5 introduces new error level defined as ‘E_STRICT’

E_STRICT will notify you when you use depreciated code.

PHP5 also introduces new default extensions.

• SimpleXML: for easy processing of XML data

• DOM and XSL

• PDO .

• Hash :gives you access to a ton of hash functions.

New Functions

PHP5 introduces new functions. You can get a list of them from the PHP Manual.

11.How failures in execution are handled with include() and require()


If the function require() cannot access to the file then it ends with a fatal error. However, the include()

function gives a warning and the PHP script continues to execute.

12.What is the main difference between require() and require_once() and

include() and include_once()?

require ‘file1’: It will include the code of the file1. In case file1 does not exist it will generate a fatal error

and script will stop executing


require_once ‘file1’ : It works the same way. The only difference between require and require_once is

that require_once does not include and evaluates file again if it has been included earlier.

include ‘file1’: This will also include and evaluates the file but in case of non

existence of the file it will not generate fatal error. It only produces warning which will not halt the script

from executing further.


‘file1’: It works the same way. The only difference between include and include_once is that

include_once does not include and evaluates file again if it has been included earlier.

Difference between require() and require_once(): require() includes and evaluates a specific file, while

require_once() does that only if it has not been included before (on the same page).

So, require_once() is recommended to use when you want to include a file where you have a lot of functions for

example. This way you make sure you don’t include the file more times and you will not get the “function re-
declared” error.

Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to

include is not found, while include() only produces a WARNING.

There is also include_once() which is the same as include(), but the difference between them is the same as the

difference between require() and require_once().

13.How can I display text with a PHP script?

Two methods are possible:


Admin has written 171 articles