简体   繁体   中英

Is there a csv files naming convention?

I must download data from external csv file which is originally named 403-002-20220107.csv.

$csvfile = "C:\wamp64\importcsv\403-002-20220701_F.csv "; //Nom du fichierCSV
if(!file_exists($csvfile)) {
     die("Fichier introuvable. Assurez-vous que vous avez précisé le bon chemin pour ce Fichier." );
}

I got this warning message:

( ! ) Warning: Octal escape sequence overflow \403 is greater than \377

as well as a "File not found" message.

After renaming the file as follows (name starting with a letter):

$csvfile = "C:\wamp64\importcsv\A403-002-20220701_F.csv "; //Nom du fichierCSV

it worked fine. Is this behaviour conforming with a specific file naming convention in PHP?

Do not use backslashes for file names - I know this is the Windows convention, but in programming languages a backslash in a string means " escape sequence is starting" which is used to put non-printable characters in a string.

You should always use forward slashes for path delimiting, even in Windows - it works fine and will not introduced unwanted behaviour.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM