How to create reusable code in php?



How to create reusable code in php?..

Answer / Roopali Sharma

In PHP, you can create reusable code by using functions, classes, and include/require statements. Functions allow you to define a block of code that can be called multiple times, reducing redundancy. Classes allow you to create objects that encapsulate data (properties) and methods (functions specific to the object). Include and require statements allow you to split your code into separate files and include them as needed.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What is the difference between for and foreach?

1 Answers  


What is the difference between $name and $$name?

1 Answers  


Explain about PHP cookies?

1 Answers  


When do you use define() and when do you use const. What are the main differences between those two?

1 Answers  


How to return ascii value of character in php?

1 Answers  


Can I include php in javascript?

1 Answers  


Tell me what is the importance of "action" attribute in a html form?

1 Answers  


Tell me what are magic methods?

1 Answers  


What is .htaccessfile and use of this file

5 Answers  


Do you know what is use of count() function in php?

1 Answers  


What is a composer?

1 Answers  


What is zend studio for?

1 Answers  


Categories