Fatal error: Call to undefined function file_exist() php - php

I have been checking whether a specific text file is existing using file_exist(), everything is written correctly and even the var_dump returns correct path but it always returns an error..
Fatal error: Call to undefined function file_exist()
my code
$filepath = "C:/Users/t*******/workspacephp/".$track_id.".txt";
var_dump($filepath);
if (file_exist($filepath)){
//do something
}else{
//do something
}

Functions is file_exists you miss the last s in the function.

Related

Fatal error: Cannot redeclare imagecreatefrombmp()

I'm working on a simple imageboard based by TinyBoard (xampp), when I try to post with image, website gives me error for some reason:
Fatal error: Cannot redeclare imagecreatefrombmp() in C:\xampp\htdocs\inc\image.php on line 584
image.php:
[1]https://pastebin.com/xqj2NAuX
(584 line = 77 line)
PHP 7.2, any help?
ANSWER:
Just change the function name to something else on line 1:
function imagecreatefrombmp2($filename)
(from user3647971)
Just change the function name to something else on line 1 :
function imagecreatefrombmp2($filename) {
the error warns you that a function named exactly like this has already been declared. It's a built-in php function: http://php.net/manual/en/function.imagecreatefrombmp.php

PHP Cannot redeclare function/Call to undefined function

I am using WooCommerce on Wordpress 4.7.1. Previously, I was running 4.7.0. When Wordpress automatically upgraded to 4.7.1, I suddenly began seeing checkouts fail to redirect to the "Thank you" page, and the UI showed that a fatal error had occurred.
Turning on debugging revealed the following error:
PHP Fatal error: Cannot redeclare get_cc() (previously declared in .../templates/emails/email-addresses.php:36) in .../templates/emails/email-addresses.php on line 36
I also confirmed that this file is never directly called with require, require_once, include, or include_once. It is, however, called with wc_get_template().
A quick search brought me to this similar question. So I added the following to email-addresses.php:
if (!function_exists('get_cc')) {
function get_cc( $code ) {
... function body
}
}
After making this change, I now receive the following error in the debug log:
PHP Fatal error: Call to undefined function get_cc() in .../templates/emails/email-addresses.php on line 32
This means that, for whatever reason, PHP believes that the function get_cc already exists, but at the same time it is undefined.
I was not the original developer. I took over the project from a contractor who is not available. It does seem clear that this file is heavily modified from the original. I am certain that the value returned by the function must be kept, so I cannot just comment out the call.
Given the information above, what options do I have to either workaround or fix this issue?
It turns out that, unlike a standard function definition in PHP, function definitions wrapped in if (!function_exists('function_name')) { ... } block must precede any call to that function.
In this case, the function definition (line 36) followed the call (line 32). This caused the function to appear to PHP as undefined:
// Not working!
$value = get_cc($code);
if (!function_exists('get_cc')) {
function get_cc( $code ) {
...
}
}
Switching the order so that the function definition came first fixed the issue:
// Working!
if (!function_exists('get_cc')) {
function get_cc( $code ) {
...
}
}
$value = get_cc($code);
As of right now, PHP's documentation does not mention this issue.

php function argument FILE type error

I try send a file into a php function
link of function:
here is that function
or:
public function resize(File $file, $destination)
{
...
}
I try this ways:
$IMAGES_DIR = $_SERVER["DOCUMENT_ROOT"];
$object->resize('http://root.com/pic.jpg',$IMAGES_DIR);
or
$object->resize($_SERVER["DOCUMENT_ROOT"].'/pic.jpg',$IMAGES_DIR);
but I got this error:
Catchable fatal error: Argument 1 passed to
Acme\MyBundle\Service\ImagineResizer::resize() must be an instance of
Symfony\Component\HttpFoundation\File\File, string given, called in
C:\WampDeveloper\Websites\root.com\webroot\images.php on line 20 and
defined in
C:\WampDeveloper\Websites\root.com\webroot\core\images\functions.php
on line 24
You should create file object first.
Try this:
$file = new Symfony\Component\HttpFoundation\File\File('http://root.com/pic.jpg');
$object->resize($file ,$IMAGES_DIR);
This is difficult to answer without knowing the code inside your resize function. However, it appears that you are simply using a filename as your first parameter but your function is expecting what you have type-hinted: a Symphony "File" object.
You need to create such an object outside of the function and pass that instead of a filename string.

Getting PHP Fatal error

I am getting the following error: PHP Fatal error: Call to undefined function updateRecord()
I know that means that PHP is unable to locate the function I am calling.
I double checked the spelling of the function name and the include file at the top of the page, and both are correct. I am not sure why PHP isn't recognizing the function in the included file.
Here is the code:
include_once('../lib/updatesEngine_lib.php');//include the file with the function
The function call:
updateRecord($jobid);
In updatesEngine_lib.php:
function updateRecord($jobid){//Code//}
I'm at a loss for why this isn't working. Especially since there are other functions in the updateEngine_lib.php file that are structured similarly that are working.
HELP!
Check your spelling for the third time or until you get it work.
There is no magic.
If it says "Call to undefined function" - so it is.
BTW, what if you call this function from updatesEngine_lib.php - does it work?

fopen: Fatal error: Can't use function return value in write context in

I cannot seem to be able to figure out why I receive:
Fatal error: Can't use function return value in write context in [path]/admincp/global.php(226) : eval()'d code on line 12
when I try to use fopen/fsockopen, and such functions to retrieve remote data.
My code is:
http://pastebin.com/crLB429N
I have tried using fopen/fread, and fsockopen/fgets. I don't even know where to start to debug this.
I would appreciate any help given, thank you!
empty() can only evaluate variables - not function return values. Your first conditional is using empty(ini_get(...))
Try:
$base_dir = ini_get('open_basedir');
if(function_exists('curl_init') && !ini_get("safe_mode") && empty($base_dir))

Categories