我正在寻找匹配字符串前 3 个字符的模式正则表达式。
例如,我有两个数字是这样的:
011569875和041568956
如果我发现第一个3个字符011,然后我将打印011569875
我是Laravel的新朋友。我想使用laravel查询构建器动态查询。
通常我可以在php中进行动态查询
$where = array(
'hello' => 'world'
);
function get($where = null){
if($where == "") $where = "";
//Function which converts where clause into queries
wheretoqueries($where); //converts where clause
$sql = "SELECT * FROM $tbl $where";
return $sql;
}
echo get($where);
Run Code Online (Sandbox Code Playgroud)
如果where子句为null,则查询为
SELECT * FROM $tbl
Run Code Online (Sandbox Code Playgroud)
如果where子句不为null,则查询为
SELECT * FROM $tbl WHERE hello = "world"
Run Code Online (Sandbox Code Playgroud)
如果键和值存在,Laravel Orm对于where子句工作正常
A::where($where)->get();
Run Code Online (Sandbox Code Playgroud)
如果where为null,则以下方法将不起作用
最近我在Nginx安装了Laravel.Laravel应用程序主页工作正常但路由页面出现404错误.我的Nginx配置如下:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.html index.htm index.php;
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$query_string;
#try_files $uri $uri/ =404;
#try_files $uri $uri/ /index.php$is_args$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
当我访问url时localhost/lar/public,它工作正常.路由被声明但是当我访问URL时localhost/lar/public/test,它会收到404错误.