English 中文(简体)
我是否需要使用次体来编制目录,或者我是否可以采用另一种代码?
原标题:Do I need to use substr() to bring up a directory or can I another code?

Everything in this file is set up in a way in which $_GET[ q ] brings up the main domain name and the other directories in the website are brought up in this manner: else if (substr($_GET[ q ], 0, 7) == quotes/ ) If I wanted to have a folder called: ultimate-deals-and-low-prices, would I use

else if (substr($_GET[ q ], 0, 30) ==  ultimate-deals-and-low-prices/ )

这样做是否有意义,或者我要以另一种方式把我的名录叫上,而不必要求网站显示目录名称。 我的理解是,这是什么样子,但我只看到它用于特性不到10。 如果我的名录具有更多的特性,我是否仍然使用替代物?

1. 本文件的开头部分是:

require_once(getcwd() ."/db/db_pagetitle.php");
print get_page_title($_GET[ q ]);
if (isset($_GET[ q ]) && $_GET[ q ]) {
    if (file_exists(getcwd() . /pages/ . $_GET[ q ] . .php )) {
        require_once(getcwd() . /pages/ . $_GET[ q ] . .php );

内容提要

else if (substr($_GET[ q ], 0, 7) ==  quotes/ ) 

我怎么说我的名录?

感谢?

问题回答

你们仍然可以使用子体,在具有10个以上的特性方面不存在问题: 换言之,如果您不考虑打字的话,你可以确切使用你贴出的代码:else (substr($_GET[q], 0, 30)=最终发行和低价/

但是,如果所有文件夹都有某种共同逻辑(如cd-ing into it or searching for a file in it),那么你不必为每个文件夹写一个其他分行,你就只能使用:

if (isset($_GET[ q ]) && $_GET[ q ]) {
    if (file_exists(getcwd() . /pages/ . $_GET[ q ] . .php )) {
        require_once(getcwd() . /pages/ . $_GET[ q ] . .php );
    } else if (is_dir(getcwd() .  /pages/  . $_GET[ q ])) {
        // do whatever you want to do with the folder
    }
}

If you would write more of your code it d be easier to understand what you re trying to do.

如果你使用多个关键词,你可以使用检测系统。

$match[]= ultimate-deals-and-low-prices/ ;
$match[]= users/ ;
$match[]= imgs/ ;
foreach($match as $k=>$v){
$l=strlen($v);
$s=substr($_GET[q],0,$l);
if ($v==$s) //Code to run...
}

无论发生什么情况?

<?php

if (file_exists($sanitizedPath)) {

} elseif (strpos($_GET[ q ], "ultimate-deals-and-low-prices/") === 0) {

} elseif (strpos($_GET[ q ], "some-other-directory/") === 0) {

}

更低的类型、较少的误差、更快。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签