PHP
Ch-1
Q1. Who is the developer of php and
when it was first developed?
Ans: Rasmus Lerdorf is the developer of php and it was
first developed in 1995.
Q2. What are the general language
features of php?
Ans: Practicality: It allows the user to build powerful
applications even with a minimum of knowledge.
Power:
It has the ability to interface with databases, manipulate from information,
and create pages dynamically.
Possibility:
It rarely bound to any single implementation solution.
Price:
It is free of charge.
Ch-2
Q3.What are the four configuration
Directive scopes?
Ans:
1. PHP_INI_PERDIR
2. PHP_INI_USER
3. PHP_INI_SYSTEM
4. PHP_INI_ALL.
Q4. What are the configurations files
of php and apache?
Ans:
PHP: The php.ini file is a simple text file,
consisting solely of comments and the directives and their corresponding
values.
Apache: apache.httpd.conf and .htaccess - When PHP is running as an Apache
module, you can modify many of the directives through either the httpd.conf file
or the .htaccess file.
Ch-3
Q5. Between
echo () and print () functions which one is the faster and why?
Ans.
1. echo() is faster because it returns
nothing(value) whereas print()
returns value.
2. echo can take multiple parameters while print can take one argument.
Q6. Which
function is used to print the output in a variable?
Ans. Sprint() function assigns the output to
a string variable rather than renders to the browser.
Q7. What
are type casting and juggling?
Ans. Type
casting: Converting values from one data type to another is known as type
casting.
Juggling: Automatic conversion is known as type juggling.
Q8. Which
variable keeps its value after functions exits?
Ans: Static variable keeps its value after
functions exits because it does not lose its value when the function exits.
Q9. What is
constant? How can you declare a constant?
Ans: A constant is a value that can’t be modified
throughout the execution of a program. Constant are declared by using the define () function.
Ex- define("PI", 3.141592);
Ex- define("PI", 3.141592);
Q10.How foreach
loop works?
Ans: For each loop is used to get value
from a list/array. It is undefined how many times the loop will be iterated.
This loop stripes each value from the array and moving the pointer closer to
the end by each iteration.
Q11. Which functions
are used to add file in a script?
Ans: include(): The include() statement will
evaluate and include a file into the location where it is called.
require (): require() operates like include(), including a template into the file in which the require() call is located.
require (): require() operates like include(), including a template into the file in which the require() call is located.
Ch-4
Q12. What
are passing arguments by reference and passing arguments by value?
If we want any changes made to an argument within a function
to be reflected outside of the function’s scope, passing the argument by
reference accomplishes this. Passing an argument by reference is done by
appending an ampersand to the front of the argument.
If we declare a variable and use it as an argument of a
function, it’s called passing arguments by value. Any changes
made to the value of that variable within the scope of the function are ignored
outside of the function.
Q13. What is
recursive function?
Recursive functions are functions that call themselves. They
offer considerable practical value to the programmer and are used to divide a
complex problem into a simple case, reiterating that case until the problem is
resolved.
Ch-5
Q14. What
are the types of key of array?
1.
Numerical keys bear no real relation to the value
other than the value’s position in the array
2.
Associative key logically bears a direct relation to
its corresponding value.
Q15. Which
functions are used to add and remove array elements?
array_unshift: Adds elements to the front of the
array.
array_push: Adds elements to the end of the
array.
array_shift: Removes the first element in an
array.
array_pop: Removes the last element in an
array.
Ch-6
Q17. What are the three
object-oriented features?
Encapsulation: The practice of separating the user
from the true inner workings of an application through well-known interfaces is
known as encapsulation.
Inheritance:
Polymorphism: defines OOP’s ability to redefine a
class’s characteristic or behavior depending upon the context in which it is
used.
Q19. What are class and object?
Class: A class is used in OOP to describe
one or more objects. It serves as a template for creating, or instantiating,
specific objects within a program.
Object: "object" refers
to a particular instance of a class where the object can be a combination of variables,
functions, and data structures.
Q20. What are the five property
scopes?
PHP supports five class property scopes:
public, private, protected, final, and static.
Q21. What is property overloading?
Ans: Property overloading continues to
protect properties by forcing access and manipulation through public methods,
yet allowing the data to be accessed as if it were a public property
Q22. What are constructor and
destructor?
Constructor: a constructor is defined as a block
of code that automatically executes at the time of object instantiation.
Destructor: is like a constructor. It automatically
destroys the objects when they are no longer needed.
Ch-7
Q23. What is object cloning?
Ans: Object cloning is the act of making a copy of an
object.
$drone1
= new Corporate_Drone();
$drone2
= clone $drone1;
Q24.
What type of
inheritance that PHP supports?
Ans:
Class Inheritance, Inheritance and Constructors, Inheritance and Late Static
Binding.
Q25. What are the abstract class and interface?
An interface allows
us to create code which specifies which methods a class must implement, without
having to define how these methods are handled.
An abstract class is a class that really isn’t supposed to
ever be instantiated but instead serves as a base class to be inherited by
other classes.
No comments:
Post a Comment