is there a way i can check if a file exist?

say i want to display an image only if the file exist

    <?php
    if(file_exists("./file")){
    

    :xbones:

      Wow, hey, fuck you. I was polite and all i said thanks you must understand that some peoples are not all experts. Find something better to do than bash newbies.

        Some more information from me

        [man]file_exists/man
        works with both directory AND file
        returns TRUE if $filename is DIRECTORY or FILE, does not have to be readble/writable

        We also have these alternative checking functions:
        [man]is_file/man .. TRUE only if is file, FALSE if is directory or NOT exists
        [man]is_dir/man .. TRUE only if is directory, FALSE if is file or NOT exists

        [man]is_readable/man .. DIR/FILE exists AND is readable, FALSE if NOT exist or NOT readable
        [man]is_writable/man.. DIR/FILE exists AND is writable, FALSE if NOT exist or NOT writable

        The best check function to use, depends on the situation.
        What you are trying to do.

        Just checking file_exsist is not always a garantee for
        you will have any use of this file/directory.
        If you can not read from it .. for example.

        The most accurate test can many times be:
        1. if is_file( $filename )
        2. if 1.= TRUE ... then CHECK is_readable( $filename ) / is_writable( $filename )
        ..... then is OKAY to try read/write
        3. if 1.= FALSE OR 2.= FALSE ... then error message

        Regards
        halojoy
        🙂

          anarchoi wrote:

          some peoples are not all experts.

          You don't need to be an expert to use a manual. You just need to be literate. And (optionally) be able to type "http://www.google.com/search?q=file+exists+PHP".

          Find something better to do than bash newbies.

          If I wanted to bash newbies I'd go over into the Newbies forum and find them there.
          I don't go over into the Newbies forum much.

            Write a Reply...