pathinfo

PHP basename() and pathinfo() with Multibytes UTF-8 file names

一笑奈何 提交于 2019-12-10 13:13:52
问题 I've found that PHP function basename(), as well as pathinfo() have a strange behaviour with multibyte utf-8 names. They remove all non-Latin characters until the first Latin character or punctuation sign. However, after that, subsequent non-Latin characters are preserved. basename("àxà"); // returns "xà", I would expect "àxà" or just "x" instead pathinfo("àyà/àxà", PATHINFO_BASENAME); // returns "xà", same as above but curiously the dirname part of pathinfo() works fine: pathinfo("àyà/àxà",

How to make pathinfo() return the right extension?

陌路散爱 提交于 2019-12-08 04:32:36
问题 $path = 'abc.jpeg'; $info = pathinfo($path,PATHINFO_EXTENSION); echo $info['extension']; This is returning 'j' for some reason, instead of 'jpeg' Is there anything I should do before calling pathinfo() ? 回答1: If you pass a second argument to pathinfo, then it doesn't return an array. You should just echo $info. From the docs (realpath): If options is used, this function will return a string if not all elements are requested. Accessing $info['extension']; happens to be accessing the first

How to make pathinfo() return the right extension?

自闭症网瘾萝莉.ら 提交于 2019-12-06 16:49:17
$path = 'abc.jpeg'; $info = pathinfo($path,PATHINFO_EXTENSION); echo $info['extension']; This is returning 'j' for some reason, instead of 'jpeg' Is there anything I should do before calling pathinfo() ? If you pass a second argument to pathinfo, then it doesn't return an array. You should just echo $info. From the docs ( realpath ): If options is used, this function will return a string if not all elements are requested. Accessing $info['extension']; happens to be accessing the first character of the string array. Thanks to Tim Cooper's comment. (int)'extension' evaluates to 0. In the

Problem using unicode in URLs with cgi.PATH_INFO in ColdFusion

醉酒当歌 提交于 2019-12-05 18:04:49
My ColdFusion (MX7 on IIS 6) site has search functionality which appends the search term to the URL e.g. http://www.example.com/search.cfm/searchterm . The problem I'm running into is this is a multilingual site, so the search term may be in another language e.g. القاهرة leading to a search URL such as http://www.example.com/search.cfm/القاهرة The problem is when I come to retrieve the search term from the URL. I'm using cgi.PATH_INFO to retrieve the path of the search page and the search term and extracting the search term from this e.g. /search.cfm/searchterm however, when unicode characters

pathinfo vs fnmatch

。_饼干妹妹 提交于 2019-12-01 17:01:03
问题 There was a small debate regarding the speed of fnmatch over pathinfo here : how to check if file is php? I wasn't totally convinced so decided to benchmark the two functions. Using dynamic and static paths showed that pathinfo was faster. Is my benchmarking logic and conclusion valid? EDIT : Using mac php from cmd PHP 5.3.0 (cli) (built: Jul 20 2009 13:56:33) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies dynamic path pathinfo 3

pathinfo vs fnmatch

ぐ巨炮叔叔 提交于 2019-12-01 16:31:25
There was a small debate regarding the speed of fnmatch over pathinfo here : how to check if file is php? I wasn't totally convinced so decided to benchmark the two functions. Using dynamic and static paths showed that pathinfo was faster. Is my benchmarking logic and conclusion valid? EDIT : Using mac php from cmd PHP 5.3.0 (cli) (built: Jul 20 2009 13:56:33) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies dynamic path pathinfo 3.2973630428314 fnmatch 3.4520659446716 x1.05 static path pathinfo 0.86487698554993 fnmatch 1.0420439243317 x1.2

nginx 隐藏 index.php 和 开启 pathinfo 模式的配置

孤街醉人 提交于 2019-11-30 10:14:49
nginx 通过 location 的规则匹配将 php 转发给 php-fpm 处理后获取结果然后返回给客户端,转发模式可以通过 unix sock 或 tcp socket 方式。百度了好多文章我是没遇到一个能完整的而且正确的把 nginx 和 php 结合的配置讲述的较为正确的,这里总结了下最基本的 nginx + php 的模式配置,以及隐藏 index.php 和 开启 pathinfo 模式的方法。 个人觉得是可以复制粘贴配置你的生产环境的,总结了很多好的博文的要点,比如隐藏 index.php 的 location 规则用的是 try_files 而不是烂大街的 if (! -e $uri) {},http 服务器级配置文件 和 虚拟主机配置文件也很好的分割开了,方便维护。 nginx 配置分两大层,基础的全局 http 配置 和 与主机相对应的 server 配置。 http 配置 nginx.conf # nginx main configure user www www; worker_processes auto; error_log /var/log/error.log crit; pid /var/nginx.pid; #Specifies the value for maximum file descriptors that can be opened

Portable and safe way to get PATH_INFO

≡放荡痞女 提交于 2019-11-30 03:51:55
问题 I'm seeking a portable way to receive the (handy) $_SERVER['PATH_INFO'] variable. After reading a while, it turns out PATH_INFO is originated from CGI/1.1, and my not always be present in all configuration. What is the best (mostly security-wise) way to get that variable - apart from extracting it manually (security concern). 回答1: Well, I'm (almost) sure that without making use of the $_SERVER superglobal keys, providing a alternative way to figure out PATH_INFO is just impossible, that being

Make PHP pathinfo() return the correct filename if the filename is UTF-8

我与影子孤独终老i 提交于 2019-11-29 02:51:36
When using PHP's pathinfo() function on a filename known to be UTF-8, it does not return the correct value, unless there are 'normal' characters in front of the special character. Examples: pathinfo('aä.pdf') returns: Array ( [dirname] => [the dir] [basename] => aä.pdf [extension] => pdf [filename] => aä ) which is fine and dandy, but pathinfo('äa.pdf') returns: Array ( [dirname] => [the dir] [basename] => a.pdf [extension] => pdf [filename] => a ) Which is not quite what I was expecting. Even worse, pathinfo('ä.pdf') returns: Array ( [dirname] => [the dir] [basename] => .pdf [extension] =>

nginx多域名配置与 pathinfo(/ 文件夹形式) URL访问不支持配置

删除回忆录丶 提交于 2019-11-28 11:11:58
多域名支持(设置域名 www.ci.com) nginx安装目录 whereis nginx 查看相关信息 1.查看nginx配置文件 /etc/nginx/nginx.conf 里面这两个是否被注释(必须开启) include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; 2.在sites-enabled或者conf.d 下面新建 ci.conf(ci为域名主体部分) 3.复制 /etc/nginx/sites-available/default 里面的内容 粘贴到ci.conf里面,更改 root 路径就可以。 4.编辑 /etc/hosts 内容 添加一行 127.0.0.1 www.ci.com 5. 重启 nginx service nginx restart或者 /etc/init.d/nginx restart (非root用户要提权才能运行成功) 6.打开你设置的域名浏览 配置nginx文件夹形式URL(pathinfo)访问支持 只须要在对应的 ci.conf (域名www.ci.com其它域名类似)中 location / { # First attempt to serve request as file, then # as directory, then fall back to