How to Fix: Error message Strict standards: Non-static method should not be called statically in php
Learn how to fix: Error message Strict standards: Non-static method should not be called statically in php.
📋 Table of Contents
The 'Strict standards: Non-static method should not be called statically in php' error message occurs when you try to call a non-static method using the static keyword.
This issue is typically caused by trying to instantiate an object from a class that does not have a static constructor or is not designed to be instantiated.
💡 Why You Are Getting This Error
- The problem arises when you use a class without creating an instance of it, which leads to the error message being displayed.
- To fix this issue, ensure that you create an instance of the class before calling any non-static methods.
✅ Best Solutions to Fix It
Create an instance of the class
- Step 1: Use the 'new' keyword to create a new instance of the class.
- Step 2: For example: $page = Page::getInstanceByName(); // Replace with your actual method call.
- Step 3: This will ensure that you are calling a non-static method on an instance of the class, rather than trying to call it statically.
Use a static constructor or redesign the class
- Step 1: If the class is not designed to be instantiated, consider adding a static constructor to initialize the object.
- Step 2: Alternatively, redesign the class to make it suitable for instantiation and then create an instance of it before calling any non-static methods.
💡 Conclusion
By following these steps, you should be able to resolve the 'Strict standards: Non-static method should not be called statically in php' error message and ensure that your PHP code runs smoothly.
❓ Frequently Asked Questions
🛠️ Related Fixes
How to Fix: Pc crashes shortly after launching game (rainbow
Fix Pc crashes shortly after launching game (rainbow six siege). Compl
How to Fix: Installing an APK on a locked down phone
Installing an APK on a locked down phone: Try using a rooted device, e
How to Fix: New PC build- no signal and no clue
Fix New PC build- no signal and no clue. Complete troubleshooting guid