How can PHP functions be restricted to only be called within a class and not externally?

To restrict PHP functions to only be called within a class and not externally, you can use the `private` or `protected` visibility modifiers when defining the function within the class. By using these modifiers, the function can only be accessed within the class itself or its subclasses, preventing external access.

class MyClass {
    private function myFunction() {
        // Function code here
    }
}