在我作为PHP程序员和C#编程初学者的日子里,我一直想知道生成独特序列号的最佳方法,例如Microsoft Office和Microsoft操作系统的工作方式.
有没有人有一个很好的指导如何处理这个,比如生成唯一序列的重要因素,防止重复等.如何创建/验证它们的小例子.
这是我正在谈论的RFC:http://tools.ietf.org/html/rfc1982.
这个问题是围绕PHP中的性能设计的,但如果您愿意,可以将其扩展为任何语言.
经过多年使用PHP并且必须比较字符串后,我了解到在正则表达式中使用字符串比较运算符对于性能是有益的.
我完全理解一些操作必须使用正则表达式来完成复杂性,但是对于可以通过正则表达式和字符串函数解决的操作.
举个例子:
PHP
preg_match('/^[a-z]*$/','thisisallalpha');
Run Code Online (Sandbox Code Playgroud)
C#
new Regex("^[a-z]*$").IsMatch('thisisallalpha');
Run Code Online (Sandbox Code Playgroud)
可以轻松完成
PHP
ctype_alpha('thisisallalpha');
Run Code Online (Sandbox Code Playgroud)
C#
VFPToolkit.Strings.IsAlpha('thisisallalpha');
Run Code Online (Sandbox Code Playgroud)
还有很多其他的例子,但你应该明白我想要的.
你应该尝试和倾向于什么版本的字符串比较?为什么?
亲爱的,我是PHP世界的一个初学者(PHP 5.3.5)我的网络服务器是在win xp上的IIS fastCGI我试图将值从HTML表单传递给php但数据未通过
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
<html>
<body>
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
按下提交后输出就像这样
欢迎!
你今年岁.
但它应该是这样的
欢迎约翰!
你今年28岁.
你能帮我解决这个问题吗?
这可能看起来像一个有趣的问题,但实际上它不是,我想禁用echo,print以及可能输出到缓冲区的其他功能,如readfile.
我之所以这样做,是为了防止客户端使用echo或print超出我的应用程序规则,强制他们编译内容并将其发送到输出类,以便管理整个缓冲区.
现在我知道我可以在我的脚本开头设置一个输出缓冲区并丢弃任何内容,但这不会包含诸如header和之类的东西set_cookie,所以我的问题可能被解释为如何控制缓冲区的头部响应
是否有任何可能的方法来管理PHP输出的所有方面,例如将回调分配给主缓冲区而不仅仅是响应主体?
我目前正在为一家公司开发一个MVC Style框架,出于安全考虑,我需要确保通过Query String传递的控制器/方法是RFC的有效字符(我找不到).
我需要能够根据PHP解释器允许的内容来验证/清理类名
例如:
class SomEFunk__YClAssName extends Controller
{
}
Run Code Online (Sandbox Code Playgroud)
我需要某种正则表达式来验证SomEFunk__YClAssName和消毒它,如果需要的话!这也是与方法相同的原则.
有一些事情需要考虑,比如
关于这个或可能表达的任何信息都会非常有用.
这是我的一些路由器代码,因此您可以看到我需要实现它的位置:
private function prepareQueryString()
{
if(strlen($this->query_string) == 0)
{
return;
}
//Remove [ending|starting|multiple] slashes
$this->query_string = preg_replace('/^\/+|\/+$|\/(?=\/)/', '', $this->query_string);
foreach(explode('/',$this->query_string) as $Key => $Value)
{
if($Key == 0)
{
$Controller = $this->AssignController($Value);
}
if($Key == 1)
{
$this->AssignMethod($Value);
}else
{
$this->AssignParam($Value);
}
}
//Build RouterVar stdClass
}
public function AssignController(String $Controller)
{
if(!empty($Controller))
{
//Sanitize
}
}
public function AssignMethod(String $Method) …Run Code Online (Sandbox Code Playgroud) 通常在 php 中处理注销哈希的方式是什么?
在很多网站上,通常有注销哈希来确认注销的用户是正确的用户,这通常是如何处理的?
例子
http://domain.com/user/logout/nil4ytwojytjwoytjwy5tw5
Run Code Online (Sandbox Code Playgroud)
nil4ytwojytjwoytjwy5tw5是哈希
只是我的研究的更新,以便其他人可以看到这是如何工作的。
我发现这种类型的攻击主要用于 xero 字节图像和 iframe 等。
如果您登录到站点 A 并且您也在浏览站点 B,那么站点 B 可以放置一个图像标签:
<img src="http://SITE_A.com/logout/" width="1" height="1" style="display:none" />
Run Code Online (Sandbox Code Playgroud)
并且因为请求实际上来自合法的登录用户,所以请求被处理。
通过在重要的表单中添加验证值,例如转账、注销等,黑客无法获取该值,因此请求将不会被执行!
谢谢你的帮助
我正在寻找一种方法来选择PHP最里面的div
例如:
<div>
<div>
<div>
-
</div>
</div>
<div>
<div>
<div>
-
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在DIV含有的-将在被选择NodeList
我使用DOMDocument和DOMXpath来抛出html,继承人和我的一个方法的例子,这样你就可以看到我的类的创建方式.
public function getkeywords()
{
foreach($this->Xpath->query('/html/head/meta[@content][@name="keywords"][1]') as $node)
{
$words = $node->getAttribute('content');
if($words)
{
return explode(',',str_replace(array(", "," ,"),",",$words));
}
return false;
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 我有这一行字符串
Fruits-banana|apple|orange:Food-fries|sausages:Desserts-ice cream|apple pie
的:(结肠)是主要议题隔板,并且|对于不同类型的子主题的分隔符.
我试图将它爆炸并将其放入数组中,我需要将结果显示在下拉菜单中: -
Fruits
banana
apple
orange
Food
fries
sausages
$result=explode(":",$data);
foreach($result as $res) {
$sub_res[]=explode("-",$res);
}
foreach($sub_res as $sub) {
//echo $sub[1]."<br>"; Over here, I can get the strings of [0]=>banana|apple|orange, [1]=>sausages|fries,
// I explode it again to get each items
$items[]=explode("|",$sub[1]);
$mainCategory[]=$sub[0]; // This is ([0]=>Fruits, ]1]=>Food, [2]=>dessert
// How do I assign the $items into respective categories?
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
$data = "google,facebook,youtube,twitter,bing";
$exp = explode(",",$data);
$rep = str_replace("facebook",$exp);
$final = implode(",",$rep);
echo $final
output// google,,youtube,twitter,bing
Run Code Online (Sandbox Code Playgroud)
如何用逗号删除此空格?
我正在寻找将模块系统实现到我的应用程序框架中的方法,模块将是以某种方式更改设计的类文件,以便自动与用户干预集成.
我的框架是一个自定义构建的框架,但与codeigniter非常相似,只是稍微轻一点.
我在模板文件中的想法是调用模块位置,并自动加载和解析模块
<html>
<head>
<title>Welcome to my site</title>
</head>
<body>
<header>
....
<?php $this->call_modules('header') ?>;
</header>
<section>
<aside>
<?php $this->call_modules('sidebar') ?>;
</aside>
</section>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
以便调用以下模块并将内容放在那里:
/system/applications/admin/modules/header/a.php
/system/applications/admin/modules/header/b.php
/system/applications/admin/modules/sidebar/a.php
/system/applications/admin/modules/sidebar/b.php
Run Code Online (Sandbox Code Playgroud)
所以对我来说似乎它可以正常工作,但问题是我之前从未构建过模块系统,而且我觉得这些被归类为钩子.
在我的脑海中,我基本上想要一个由1个类文件和模板组成的简单系统,如果需要,calss文件可能如下所示:
class Module_HelloWorld extends Module
{
public static function info()
{
return array(
'name' => 'Hello Word',
'version' => '1.0.0',
'description' => 'Dispalys "hello World"',
'author' => 'Robert Pitt',
);
}
public function execute($context,$action)
{
//$context would be the current view at the point of execution for the …Run Code Online (Sandbox Code Playgroud)