小编Ali*_*ien的帖子

正则表达式匹配PHP中字符串的前3个字符

我正在寻找匹配字符串前 3 个字符的模式正则表达式。
例如,我有两个数字是这样的: 011569875041568956
如果我发现第一个3个字符011,然后我将打印011569875

php regex

5
推荐指数
1
解决办法
781
查看次数

Laravel动态在哪里使用查询生成器查询

我是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,则以下方法将不起作用

php mysql laravel-5 laravel-eloquent

5
推荐指数
2
解决办法
3368
查看次数

Nginx服务器laravel路由目录404错误

最近我在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错误.

php nginx laravel-5

2
推荐指数
1
解决办法
1682
查看次数

标签 统计

php ×3

laravel-5 ×2

laravel-eloquent ×1

mysql ×1

nginx ×1

regex ×1