Which is faster to parse? Serialized string or plain PHP or something else?

So, for performance reasons, I need my app to store big arrays of data in a way that's fast to parse. I know JSON is readable but it's not fast to decode. So it's I should either convert my array into pure php code or I have to serialize it and then deserialize. So, which is faster? Are there any better solutions? I could do a benchmark myself, but It's always better to consi

解析速度更快? 序列化的字符串或普通的PHP或其他东西?

所以,出于性能方面的原因,我需要我的应用程序以快速解析的方式存储大数据。 我知道JSON是可读的,但解码速度并不快。 所以这是我应该将我的数组转换为纯粹的PHP代码或我必须序列化,然后反序列化。 那么,哪个更快? 有没有更好的解决方案? 我可以自己做一个基准测试,但总是考虑其他人的经验:) 更多信息:通过大数组我的意思是从调用print_r()返回大约2MB值的数据! 并将它转换为纯php代码我的意思是:假设这是我

*fast* serialize/unserialize?

I have a PHP script that builds a binary search tree over a rather large CSV file (5MB+). This is nice and all, but it takes about 3 seconds to read/parse/index the file. Now I thought I could use serialize() and unserialize() to quicken the process. When the CSV file has not changed in the meantime, there is no point in parsing it again. To my horror I find that calling serialize() on my i

*快速*序列化/反序列化?

我有一个PHP脚本,通过一个相当大的CSV文件(5MB +)构建二叉搜索树。 这很好,但是大约需要3秒来读取/解析/索引文件。 现在我想我可以使用serialize()和unserialize()来加快进程。 在此期间,如果CSV文件没有改变,则再次解析它没有意义。 令我惊恐的是,我发现在我的索引对象上调用serialize()需要5秒钟,并产生一个巨大的(19MB)文本文件,而unserialize()需要27秒才能读取它。 改进看起来有点不同。 ;-) 所以 -

Get Website Title From User Site Input

I'm trying to get the title of a website that is entered by the user. Text input: website link, entered by user is sent to the server via AJAX. The user can input anything: an actual existing link, or just single word, or something weird like 'po392#*@8' Here is a part of my PHP script: // Make sure the url is on another host if(substr($url, 0, 7) !== "http://"

从用户网站输入获取网站标题

我试图获取用户输入的网站的标题。 文本输入:用户输入的网站链接通过AJAX发送到服务器。 用户可以输入任何内容:实际存在的链接,或者只是一个单词,或者像'po392#* @ 8' 这是我的PHP脚本的一部分 : // Make sure the url is on another host if(substr($url, 0, 7) !== "http://" AND substr($url, 0, 8) !== "https://") { $url = "http://".$url; } // Extra

In what order are conditions inside an IF checked?

I had a problem were I need to check two conditions, A and B. The thing is, checking B takes a lot of time, and if A is already false I don't need to check for B. I can easily do: if(a) if(b) // Do something But I wonder, if I do if(a AND b) , does the PHP interpreter check for A and B and then apply the AND operator? Or does it already "know" there is an AND operator and s

IF中的条件按什么顺序检查?

我有一个问题,我需要检查两个条件,A和B.事情是,检查B需要很多时间,如果A已经是假的,我不需要检查B.我可以很容易地做到: if(a) if(b) // Do something 但是我想知道,如果我这样做if(a AND b) ,PHP解释器检查A和B,然后应用AND运算符吗? 或者它已经“知道”有一个AND运算符,所以如果A是假的,它不检查B? 你所说的就是所谓的短路评估。 我不是一个PHP专家,但在google上快速搜索解释说它是用PHP实现的。 所以

Why (false and false or true) returns true

var_dump(false and false || true); // result: bool(false) (false and false || true) returns false as expected. var_dump(false and false or true); // result: bool(true) but (false and false or true) returns true. I have no logical explanation why this is happening. && and || have higher precedence on and and or You can see Operator precedence on PHP documentation So <?php va

为什么(错误和错误或真实)返回true

var_dump(false and false || true); // result: bool(false) (false and false || true)按预期返回false。 var_dump(false and false or true); // result: bool(true) 但是(false and false or true)返回true。 我没有合理的解释为什么会发生这种情况。 &&和|| 具有更高的优先级上and和or 您可以在PHP文档中看到运算符优先级 所以 <?php var_dump(false and false || true); // eq: false and (true or

, AND and &&

I am know about priority, but if we have one simple condition: if ($a == 1 AND $b == 2){ } Is there any difference with if ($a == 1 && $b == 2){ } ? There is no difference at all, except that perhaps using AND is somewhat more readable. EDIT: just checked, and there is a small difference in the operators precedence, see http://php.net/manual/en/language.operators.precedence.php

,AND和&&

我知道优先权,但如果我们有一个简单的条件: if ($a == 1 AND $b == 2){ } 有没有什么区别 if ($a == 1 && $b == 2){ } ? 根本没有区别,除了可能使用AND更具可读性。 编辑:只是检查,并在运营商的优先权有一个小的差异,请参阅http://php.net/manual/en/language.operators.precedence.php 他们做同样的事情。 &&具有更高的优先级是AND虽然。 之前有人问过这个问题: PHP和/或关键字 PHP

PHP if statement: use "OR" or

Possible Duplicate: PHP - and / or keywords if($foo == 0 or $bar == 1 || $baz == 2) { ... } Is it better to use "or" or || and is there any significant difference between them? It's basically a matter of choice. There is a difference however, when it comes to operand precedence: if ( false && false || true ) // true if ( false AND false || true ) // false See

PHP if语句:使用“OR”或

可能重复: PHP和/或关键字 if($foo == 0 or $bar == 1 || $baz == 2) { ... } 使用“或”还是||更好? 他们之间有什么重大区别? 这基本上是一个选择的问题。 然而,当涉及操作数优先级时有一个区别: if ( false && false || true ) // true if ( false AND false || true ) // false 在这里看到它的行动:http://codepad.viper-7.com/zvFPzR

What does "or" in php mean?

Possible Duplicate: PHP - and / or keywords I saw several bits of PHP code using or in a way I was unfamiliar with. For example: fopen($site,"r") or die("Unable to connect to $site"); Is this equal to this || ? Why would you use this instead of a try catch block? What will cause the program run the or die() ? It is for the most part, but... The reason for the two different variatio

“或”在PHP中是什么意思?

可能重复: PHP和/或关键字 我看到几个PHP代码使用or以我不熟悉的方式。 例如: fopen($site,"r") or die("Unable to connect to $site"); 这是否等于|| ? 为什么你会用这个来代替try catch块? 什么会导致程序运行or die() ? 这是大部分,但... “和”和“或”运算符的两种不同变体的原因是它们以不同的优先级运行。 见http://php.net/manual/en/language.operators.logical.php or等于|| || 除外 比or更高

PHP shorthand logical operators AND and OR

Possible Duplicates: PHP - and / or keywords PHP shorthand syntax Quick question. I keep seeing shorthand expressions in libraries around the place, and despite having been a PHP developer for over 3 years, I struggle to quite see how the following would evaluate. What exactly does the PHP interpreter do with the following shorthand lines of code when it encounters them? <?php de

PHP简写逻辑运算符AND和OR

可能重复: PHP和/或关键字 PHP简写语法 快速提问。 我一直在这个地方的图书馆里看到速记表达,尽管我已经是一名PHP开发人员已经有3年多了,但我很难理解下面的评估方式。 当PHP解释器遇到它时,它究竟用下面这些简短的代码行来做什么? <?php defined('foo') OR exit('foo is not defined!'); $foo AND $this->bar(); 我猜测它很明显是有条件的执行 - 也就是说,除非第一位是真的,否则第二条语句不

PHP : Difference between '&&' and 'AND'

Possible Duplicate: PHP - and / or keywords Dear All, I would like to get clear in mind about conditional operators in php. Please clarify me what is the difference between '&&' and 'AND' in php? Thanks in Advance They do the same thing, but && has higher precedence than AND . http://php.net/manual/en/language.operators.precedence.php

PHP:'&&'和'AND'之间的区别

可能重复: PHP和/或关键字 亲爱的大家, 我想清楚在php中的条件运算符。 请澄清我在'&&'和'AND'之间的区别是什么? 提前致谢 他们做同样的事情,但&&比AND具有更高的优先级。 http://php.net/manual/en/language.operators.precedence.php