Quick Table of Contents
[Edit] Allowed memory size of X bytes exhausted
This error renders when a script exceeds the default memory_limit setting inside your PHP configuration file(php.ini) on your server. Best practice is to always make more efficient programs instead of maxing out the PHP memory limited allocated. If you must allow a beefy memory hog file to run you can check the fix suggestions below. You may have to restart Apache to have any php.ini changes take place, especially on local PHP environments. How can i fix itAdjust your php.ini file memory_limit setting to something higher using this line:memory_limit = 20MOr use the ini_set() php function directly in the script that is exceeding default memory limits. Example: ini_set("memory_limit","20M"); [Edit] Fatal Error: Call to undefined function
This error will render when you call a function to run that does not exist to the script, or you are not using the proper case when calling the function. When working with classes in PHP it often renders when you forget to place $this-> when refering to on object. How can i fix itBe sure to only call functions by name that exist, and be sure to use the proper casing. One can use the function_exists('sayHi') php function in a condition statement before attempting to run any function. That function was made to see if functions exist in the script.<?php function sayHi(){ echo "hi"; } if (function_exists("sayHi")) { sayHi(); } ?>Or just make sure you call the correct function name <?php function sayHi(){ echo "hi"; } sayhi();// Wrong sayHi();// Right ?> [Edit] Fatal Error: Call to undefined method
This error usually renders when a coder working with PHP classes forgets to define an object correctly in their calling script, then attempts to access that object's methods. It can also render when you forget to place $this-> when refering to on object and its methods. How can i fix itUse the method_exists() php function it will check to see if a method exists or not in your script before you try to use it, thus defeating this Fatal Error. However it is best to learn how to properly define object instances and communicate through them to defeat this error most efficiently, and not require a check like the one below.if (method_exists($myObjectInstance,"method")) { echo "methodName is available for use"; } else { echo "methodName is NOT available for use"; } [Edit] Fatal Error: Cannot redeclare
This error usually means that you are trying to declare a function or class that has already been declared in your script. How can i fix itDo not declare things twice, like functions, classes, etc...//---------------------------------------- // Let us say you have this function //---------------------------------------- function sayHi(){ echo "hi"; } // That same function cannot be redeclared function sayHi(){ echo "Goodbye"; } //---------------------------------------- // Same goes for classes //---------------------------------------- class sayHi{} // Do not declare any class twice class sayHi{} |
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
© Advanced Web Core. All rights reserved