Should I use @ in my PHP code?

如果我在代码中使用@ ,它会影响性能吗? This article is helpful for answering your question: http://anvilstudios.co.za/blog/php/how-to-ignore-errors-in-a-custom-php-error-handler/ Specifically the section "@ has its uses": Now one really should use the @ operator very sparingly, handling errors instead of suppressing them. But there are a small number of situations I can think of wh

我应该在我的PHP代码中使用@吗?

如果我在代码中使用@ ,它会影响性能吗? 这篇文章有助于回答你的问题:http://anvilstudios.co.za/blog/php/how-to-ignore-errors-in-a-custom-php-error-handler/ 特别是“@有其用途”部分: 现在应该非常谨慎地使用@操作符,处理错误而不是压制它们。 但是我可以想到的情况很少,可能需要抑制一些PHP错误。 让我举两个例子: 您可能正在使用一些使用了@大型外部库,因此需要能够像库的作者所预期的那样忽略这些错误,否

PHP functions and @functions

Basically, I've seen people using @ before their function calls, not for every function, but for some kind of extension functions like file_get_contents() , mysql_connect() and so on. And yes, the question is: For what purpose are there these @ s before function calls? Or in other words, what is the difference between @file_get_contents() and file_get_contents() ? @ is an error control

PHP函数和@functions

基本上,我已经看到人们在他们的函数调用之前使用@ ,而不是每个函数,但是对于某些类型的扩展函数,如file_get_contents() , mysql_connect()等等。 是的,问题是:为什么函数调用之前存在这些@ s? 换句话说, @file_get_contents() file_get_contents()和file_get_contents()之间有什么区别? @是一个错误控制操作员。 基本上它抑制了错误。 这是PHP的error control operator用于抑制函数调用产生的任何错误。 @func

'At' symbol before variable name in PHP: @$

I've seen function calls preceded with an at symbol to switch off warnings. Today I was skimming some code and found this: $hn = @$_POST['hn']; What good will it do here? The @ is the error suppression operator in PHP. PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be

PHP中变量名称前的'At'符号:@ $

我看到函数调用之前有一个符号来关闭警告。 今天我正在浏览一些代码,并发现这一点: $hn = @$_POST['hn']; 它在这里有什么好处? @是PHP中的错误抑制运算符。 PHP支持一个错误控制运算符:at符号(@)。 当在PHP中添加表达式时,可能会忽略可能由该表达式生成的任何错误消息。 看到: 错误控制操作符 @运算符的不良用法 更新: 在你的例子中 ,它被用在变量名之前,以避免那里的E_NOTICE错误。 如果在$_POST

What is the use of the @ symbol in PHP?

I have seen uses of @ in front of certain functions, like the following: $fileHandle = @fopen($fileName, $writeAttributes); What is the use of this symbol? 它抑制错误消息 - 请参阅PHP手册中的错误控制操作符。 It suppresses errors. See Error Control Operators in the manual: PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages t

PHP中@符号的用法是什么?

我在某些函数前看到了@用法,如下所示: $fileHandle = @fopen($fileName, $writeAttributes); 这个符号有什么用? 它抑制错误消息 - 请参阅PHP手册中的错误控制操作符。 它可以抑制错误。 请参阅手册中的错误控制操作员: PHP支持一个错误控制运算符:at符号(@)。 当在PHP中添加表达式时,可能会忽略可能由该表达式生成的任何错误消息。 如果你已经用set_error_handler()设置了一个自定义的错误处理函数,那么它

Double not (!!) operator in PHP

What does the double not operator do in PHP? For example: return !! $row; What would the code above do? It's not the "double not operator", it's the not operator applied twice. The right ! will result in a boolean, regardless of the operand. Then the left ! will negate that boolean. This means that for any true value (numbers other than zero, non-empty strings and ar

在PHP中双重(!!)运算符

双重非运算符在PHP中做什么? 例如: return !! $row; 上面的代码会做什么? 这不是“双重操作者”, 而是非操作员施加两次。 正确! 无论操作数如何,都会导致一个布尔值。 然后左! 将否定布尔值。 这意味着对于任何真值(非零数字,非空字符串和数组等),您将获得布尔值TRUE ,并且对于任何假值(0,0.0, NULL ,空字符串或空数组),您将获得布尔值FALSE 。 它在功能上等同于转换为boolean : return (bool)$row

What is the PHP operator % and how do I use it in real

What is the explanation for PHP's operator % in full detail? Including examples would be nice! It's the modulus operator, which gives the integer remainder of a division eg 7 / 2 = 3.5 // 3 remainder 1 7 % 2 = 1 // the remainder Obvious real world example is working out whether a number is odd or even if (($n % 2) == 0) the number is even, else it's odd... useful when you

什么是PHP运营商?我如何真正使用它

PHP操作符%的详细解释是什么? 包括例子会很好! 它是模数运算符,它给出了除法的整数余数,例如 7 / 2 = 3.5 // 3 remainder 1 7 % 2 = 1 // the remainder 明显的现实世界的例子是确定一个数字是奇数还是偶数 如果(($ n%2)== 0)数字是偶数,否则它是奇怪的......当你想以不同颜色在表格中显示交替行 %是模数运算符。 一个例子 $num1 = 160; $num2 = 15; $result = $num1 % $num2; echo "The modulus of t

What does the percent sign mean in PHP?

这到底是什么意思? $number = ( 3 - 2 + 7 ) % 7; It's the modulus operator, as mentioned, which returns the remainder of a division operation. Examples: 3%5 returns 3, as 3 divided by 5 is 0 with a remainder of 3. 5 % 10 returns 5, for the same reason, 10 goes into 5 zero times with a remainder of 5. 10 % 5 returns 0, as 10 divided by 5 goes exactly 2 times with no remainder. In the ex

PHP中百分号的含义是什么?

这到底是什么意思? $number = ( 3 - 2 + 7 ) % 7; 如上所述,它是模数运算符,它返回除法运算的其余部分。 例子: 3%5返回3,因为3除以5是0,余数是3。 5 % 10返回5,出于同样的原因,10进入5次零次,其余5次。 10 % 5返回0,因为10除以5就是2次,没有余数。 在你发布的例子中, (3 - 2 + 7)为8,给你8 % 7 ,所以$number将是1 ,这是8/7的剩余部分。 它是模数运算符: $a % $b的=余$a除以$b 。 它通常用于“每N个

and / or keywords

Is && the same as "and", and is || the same as "or" in PHP? I've done a few tests, and it seems they behave the same. Are there any differences? If not, are there any other PHP signs that have word equivalents and do you think it makes the code easier to read? and and or have higher lower precedence than && and || . To be more exact && and

和/或关键字

&&与“和”相同,并且是|| 与PHP中的“或”相同? 我做了一些测试,看起来他们的表现一样。 有什么区别吗? 如果没有,是否还有任何其他PHP标志有相同的字词,您认为它使代码更易于阅读吗? and和or具有比&&和||更高的低优先级 。 更确切地说&&和|| 比和赋值运算符( = )具有更高的优先级,而and和or具有更低的优先级。 http://www.php.net/manual/en/language.operators.precedence.php 通

'AND' vs '&&' as operator

I have a codebase where developers decided to use AND and OR instead of && and || . I know that there is a difference in operators' precedence ( && goes before and ), but with the given framework (PrestaShop to be precise) it is clearly not a reason. Which version are you using? Is and more readable than && ? Or is there no difference? If you use AND and OR ,

'AND'和'&&'作为运算符

我有一个代码库,开发人员决定使用AND和OR来代替&&和|| 。 我知道运算符的优先级有所不同( &&在之前and ),但是对于给定的框架(PrestaShop是精确的),显然不是一个理由。 你正在使用哪个版本? 是and不是更具可读性&& ? 还是没有区别? 如果你使用AND和OR ,你最终会被这样的事情绊倒: $this = true; $that = false; $truthiness = $this and $that; 想猜测$truthiness等于什么?

What does =& mean in PHP?

Consider: $smarty =& SESmarty::getInstance(); What is the & for? It passes by reference. Meaning that it won't create a copy of the value passed. See: http://php.net/manual/en/language.references.php (See Adam's Answer) Usually, if you pass something like this: $a = 5; $b = $a; $b = 3; echo $a; // 5 echo $b; // 3 The original variable ( $a ) won't be modified if yo

PHP中的=是什么意思?

考虑: $smarty =& SESmarty::getInstance(); 什么是& for? 它通过引用传递。 这意味着它不会创建传递的值的副本。 见:http://php.net/manual/en/language.references.php(见亚当的答案) 通常,如果你传递这样的东西: $a = 5; $b = $a; $b = 3; echo $a; // 5 echo $b; // 3 如果更改第二个变量( $b ),原始变量( $a )将不会被修改。 如果你通过参考传递: $a = 5; $b =& $a; $b = 3; echo $