Can methods be written and used outside of a class in PHP?

Yes, in PHP, methods can be written and used outside of a class by defining them as standalone functions. These functions can then be called directly without the need for an object instance.

// Define a method outside of a class
function greet($name) {
    echo "Hello, $name!";
}

// Call the method
greet("John");