Junior — Middle
Can you explain what a procedure is in programming?
sobes.tech AI
Answer from AI
A procedure in programming is a named block of code that performs a specific task and can be called from different parts of a program. In PHP, procedures are usually implemented as functions that can accept parameters and perform actions, but do not necessarily return a value.
Example of a procedure in PHP:
function sayHello($name) {
echo "Hello, $name!";
}
sayHello("World"); // Outputs: Hello, World!
Procedures help structure code, make it more readable, and avoid repeating the same fragments.