Difference between revisions of "Short Notes on PHP"
From PaskvilWiki
(Created page with "== Convert Accented Characters to Non-Accented == <pre>setlocale(LC_ALL, "en_US.utf8"); $translit = iconv("utf-8", "us-ascii//TRANSLIT", $_GET['orig_name']);</pre> '''Note''': ...") |
(No difference)
|
Revision as of 21:13, 1 June 2012
Convert Accented Characters to Non-Accented
setlocale(LC_ALL, "en_US.utf8"); $translit = iconv("utf-8", "us-ascii//TRANSLIT", $_GET['orig_name']);
Note: On *nix systems, you can check for supported locales using `locale -a`.
Note: Instead of hard-coding the locale to use, you could also use values of HTTP_ACCEPT_LANGUAGE and HTTP_ACCEPT_CHARSET, sent by the browser, to tailor the input locale.
Upload a File using cURL
<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($ch, CURLOPT_URL, _VIRUS_SCAN_URL); curl_setopt($ch, CURLOPT_POST, true); // same as <input type="file" name="file_box"> // notice the '@' ahead of the path! $post = array( "file_box"=>"@/path/to/myfile.jpg", ); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $response = curl_exec($ch); // if $response === false, something went wrong ?>