file-exists

php echo if two conditions are true

99封情书 提交于 2019-12-04 03:11:29
The actual code looks like this: if (file_exists($filename)) {echo $player; } else { echo 'something'; but it displays the player even if the id is not called from the url i need something like this: check if $filename exists and $id it is not empty then echo $player if else echo something else i check if $id is not empty with if(empty($id)) echo "text"; but i don't know how to combine both of them Can somebody help me? Thank you for all your code examples but i still have a problem: How i check if $id is not empty then echo the rest of code if (!empty($id) && file_exists($filename)) Just use

In MATLAB exist( x, 'file' ) takes forever

半城伤御伤魂 提交于 2019-12-04 00:14:11
I am using exist(x, 'file') to check for the existence of a file on my machine. The execution of this command takes FOREVER (over 10 seconds per call!). My matlabpath is not too long (about 200 entries) and all folders on path are on my local drive (no network). Why does exist takes forever? Is there a way to make it run FASTER? PS, This call to exist is part of Matlab's execution of loadlibrary . So, if you are calling loadlibrary and you don't know why it takes forever - this question is also for you. Andrew Janke Here's one idea. You could put the directory containing those header files up

checking if file exists in a specific directory

狂风中的少年 提交于 2019-12-03 22:35:55
I am trying to check for a specific file in a given directory. I don't want the code but I want to fix the one I have. The only difference in this question, is that I look for files with an extension .MOD . I have the code ready:- public static int checkExists(String directory, String file) { File dir = new File(directory); File[] dir_contents = dir.listFiles(); String temp = file + ".MOD"; boolean check = new File(temp).exists(); System.out.println("Check"+check); // -->always says false for(int i = 0; i<dir_contents.length;i++) { if(dir_contents[i].getName() == (file + ".MOD")) return

php file_exists is returning false even if file exist on my linux

自闭症网瘾萝莉.ら 提交于 2019-12-03 16:32:23
This question has been asked many times, but none of the answers I found helped me. I am trying to get php file_exists() to work. The only scenario when it works is when the php-file is in the same directory as the file to use file_exist() on and only using the file name (i.e. excluding the path). But it's not consequent behaviour, please see below. Som information: safe_mode=off no symlinks for directory 28 no whitespace in the file name All directories in /var/www/html/smic/upload/28/ has apache:apache 777 as permission. Using php 5.3 PHP: echo getcwd() clearstatcache(); $file = 'file:///var

Makefile - Make dependency only if file doesn't exist

社会主义新天地 提交于 2019-12-03 15:26:27
问题 Like the title says, I would like to make a dependency only if a certain file does not exist, NOT every time it updates. I have a root directory (the one with the makefile) and in it a sub-directory called "example". In my root directory are four .h files (functions.h, parser.h, node.h, and exception.h) which I would like to copy to the "example" sub-directory if those .h files do not already exist in "examples". Unfortunately I can not just make a standard dependency to check for the header

file_exists() is too slow in PHP. Can anyone suggest a faster alternative?

↘锁芯ラ 提交于 2019-12-03 14:27:58
问题 When displaying images on our website, we check if the file exists with a call to file_exists() . We fall back to a dummy image if the file was missing. However, profiling has shown that this is the slowest part of generating our pages with file_exists() taking up to 1/2 ms per file. We are only testing 40 or so files, but this still pushes 20ms onto the page load time. Can anyone suggest a way of making this go faster? Is there a better way of testing if the file is present? If I build a

Python, subprocess, call(), check_call and returncode to find if a command exists

我与影子孤独终老i 提交于 2019-12-03 10:58:05
I've figured out how to use call() to get my python script to run a command: import subprocess mycommandline = ['lumberjack', '-sleep all night', '-work all day'] subprocess.call(mycommandline) This works but there's a problem, what if users don't have lumberjack in their command path? It would work if lumberjack was put in the same directory as the python script, but how does the script know it should look for lumberjack? I figured if there was a command-not-found error then lumberjack wouldn't be in the command path, the script could try to figure out what its directory is and look for

file_exists() or is_readable()

此生再无相见时 提交于 2019-12-03 04:26:19
Which one should you use when you want to include a PHP file? if(file_exists($file) require "$file"; or if(is_readable($file) require "$file"; ? file_exists() or is_readable() Which one should you use when you want to include a PHP file? This depends on if you want to know if only a file or a directory exists, or if either is fine, and if you need to check if readable or not. Sometimes you only care the file and/or directory exist, and don't need to read, sometimes you also need to read. Options file_exists() Checks whether a file or directory exists. If you explicitly only want to know if a

How to check whether file exists in Qt in c++

自闭症网瘾萝莉.ら 提交于 2019-12-03 02:31:14
问题 How do I check whether a file exists in a given path or not in Qt? My current code is below: QFile Fout("/Users/Hans/Desktop/result.txt"); if(!Fout.exists()) { eh.handleError(8); } else { // ...... } But when I run the code it is not giving the error message specified in handleError even though the file I mentioned in the path does not exist. 回答1: (TL;DR at the bottom) I would use the QFileInfo -class (docs) - this is exactly what it is made for: The QFileInfo class provides system

Why does PHP think this folder doesn't exist?

你。 提交于 2019-12-02 20:04:48
问题 I'm having trouble creating a folder and writing into it. if(file_exists("helloFolder") || is_dir("helloFolder")){ echo "folder already exists"; } else { echo "no folder, creating"; mkdir("helloFolder", 0755); } This returns "no folder, creating" even when the folder already exists. Then I get this error: Warning: mkdir() [function.mkdir]: No such file or directory in script.php on line 18 Warning: file_put_contents(/filename.txt) [function.file-put-contents]: failed to open stream: