Is it possible in PHP to prevent "Fatal error: Call to undefined function"?

Asked
Active3 hr before
Viewed126 times

7 Answers

errorfunctionpreventpossible
90%

No. Fatal errors are fatal. Even if you were to write your own error handler or use the @ error suppression operator, E_FATAL errors will still cause the script to halt execution.,It's always a better idea to code defensively around a potential (probable?) error than it is to just let the error happen and deal with it later anyway.,If you would like to suppress this error while working with objects use this function:,//Report all error except notice

Example codez:

try {
   some_undefined_function_or_method();
} catch (\Error $ex) { // Error is the base class for all internal PHP error exceptions.
   var_dump($ex);
}
load more v
88%

In PHP, is there any way that I can ignore functions that are undefined instead of throwing a fatal error that is visible in the browser?—i.e., Fatal error: Call to undefined function,It's always a better idea to code defensively around a potential (probable?) error than it is to just let the error happen and deal with it later anyway.,The only way to handle this is to use function_exists() (and possibly is_callable() for good measure) as in your example above. ,I know that there is the practice of wrapping all custom functions in a conditional as below, but is there a programmatic way to get this effect?

I know that there is the practice of wrapping all custom functions in a conditional as below, but is there a programmatic way to get this effect?

if (function_exists('my_function')) {

   // use my_function() here;

}
load more v
72%

Try checking to see
if the PHP MySQL extension module is being loaded:

   <
   ? php
phpinfo(); ?
>

If it 's not there, add the following to the php.ini file:

extension = php_mysql.dll

Save and Restart You Apache HTTP Server
load more v
65%

In the last 3 days I've been struggling to get a couple of PHP apps(phpmyadmin and drupal 7) working on my Kubuntu 15.04 box and consistently receive a "PHP Fatal error: Call to undefined function" error I cannot figure out why.,--> the content of the referred file on line 5095 being:, Are there any gaps in the range of gravitational wave frequencies we can detect? , Idiom or phrase for expressing one's skill/talent has not decayed

To add this particular extension to your system, issue this command:

sudo apt - get install php5 - json
load more v
75%

Most likely cause: the module is specific for Drupal version 4.6.,You may also get this error if you use php snippets in pages or blocks that display forms. Disable such snippets before upgrading., This error usually occurs on the modules settings page, but also on other module pages containing forms.,After installing a module on Drupal 4.7 you get the error:

After installing a module on Drupal 4.7 you get the error:

Fatal error: Call to undefined
function: form_ * () in [module_path]
40%

As there are other things in your functions.php code, is it possible that one of those is causing the problem?,The error message looks as though the …/controls/functions.php file is not being loaded or there are errors in the included file,,And this is function.php,Does your functions.php file have the php open and close tags around it, outside of the section you posted?

And this is function.php

function save_stock(){

include 'connection.php';

if(isset($_POST['addstock']))
    {
      $drugname=$_POST['drug_name'];
      $category=$_POST['category'];
      $description=$_POST['description'];
      $company=$_POST['company'];
      $supplier=$_POST['supplier'];
      $quantity=$_POST['quantity'];
      $cost=$_POST['cost'];
      $totalcost=$_POST['totalcost'];
      $date=$_POST['datesupplied'];
      

  $insert="insert into stock_details (drug_name,category,description,company,supplier,quantity,cost,totalcost,datesupplied) values('$drugname','$category','$description','$company','$supplier','$quantity','$cost','$totalcost','$date')";

  $run_insert=mysql_query($insert);
      if($run_insert === FALSE) { 
          die(mysql_error()); // TODO: better error handling
      }
      
      if($run_insert)
      {
        echo "<script>alert ('stock Details Successful Saved')</script>";
        exit();

      }
      else
      {
        echo "<script>alert ('Error While Saving stock Details')</script>";
        exit();
      
      }
}

}
load more v
22%

Fatal error: Call to undefined function wp() in /home/content/33/7211533/html/someSite/wp-blog-header.php on line 14, WordPress Development help chat , WordPress Development Meta ,WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.

The correct path should be this one instead:

/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if (!defined('ABSPATH'))
   define('ABSPATH', dirname(__FILE__).
      '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH.
   'wp-settings.php');
load more v

Other "error-function" queries related to "Is it possible in PHP to prevent "Fatal error: Call to undefined function"?"