更好的错误处理方式?(Better way of error handling?)
错误处理的最佳方式是什么? 这就是我想到的:
class test { public static function Payment($orderid, $total) { if (empty($orderid) && empty($total)) { return array('status' => 'fail', 'error' => 'Missing Data'); } } }
我听说过Try / Exceptions,但是如何将它应用到我的代码中? 如果你能提供一个很棒的例子!
What are best way of error handling? This is what I came up with:
class test { public static function Payment($orderid, $total) { if (empty($orderid) && empty($total)) { return array('status' => 'fail', 'error' => 'Missing Data'); } } }
I heard about Try/Exceptions but how to fit that into my code? If you could provide example that would be great!
原文:https://stackoverflow.com/questions/5967153
最满意答案
浏览器喜欢在渲染时将所有空格压缩到单个空间中(查看此StackOverflow问题以获取更多信息)。 这是由浏览器引起的,而不是由样式表引起的。 这是HTML的一个属性,其中新行将被视为空格。
要解决此问题,您可以将所有
<a>
标记放在同一行,但代码看起来不是很干净(如此JSFiddle所示)Browsers like to condense all whitespace into a single space when rendering (view this StackOverflow question for more information). This is caused by the browser, not by your stylesheet. This is a property of HTML in which new lines are to be treated as spaces.
To remedy the issue, you can place all of your
<a>
tags on the same line, however the code won't look very clean (as shown on this JSFiddle)
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
nnoremap
... 是你在找什么。 例如,如果你的MyFunc()返回一个布尔值,你可以这样做:nnoremap MyFunc()?"\ ":"\ "所以这将空间映射到普通空间或Enter取决于MyFunc()结果 您也可以让MyFun()返回一个字符串,然后您可以直接在键映射中使用它。 阅读:h :map-expr了解详情。 nnoremap ... is what you are looking for. E.g. i ... -
我终于找到了这个错误 - 正如我所料,它是非常愚蠢的: 我正在将这些变化合并到错误的背景中。 I finally found the bug - and as I expected, it was quite stupid one: I was merging the changes into the wrong context.
-
如果我理解的很好,你可以使用: yourstring.replaceAll(" (?! )", ""); If I understand well, you can use : yourstring.replaceAll(" (?! )", "");
-
没有空间的宏(Macro Without Space)[2023-08-03]
您可以使用令牌粘贴操作符## : #define diagnostic_arg(message,...) fprintf(stderr,L##message,__VA_ARGS__) 但是,使用TEXT宏可能会更好(如果您在Visual Studio中),无论UNICODE是否被定义,它都会做正确的事情: #define diagnostic_arg(message,...) fprintf(stderr,TEXT(message),__VA_ARGS__) 如果你不是,可以像这样定义TEXT : #i ... -
图像是内联元素,因此它们后面有一个空格(如元素)。 要删除该空白区域,请将其更改为块元素,如下所示: img{ display:block; } Images are inline elements, so they have a white space after them (like a element). To remove that white space, change them to block elements like this : img{ di ...
-
为什么有空间?(Why is there a space?)[2023-12-04]
浏览器喜欢在渲染时将所有空格压缩到单个空间中(查看此StackOverflow问题以获取更多信息)。 这是由浏览器引起的,而不是由样式表引起的。 这是HTML的一个属性,其中新行将被视为空格。 要解决此问题,您可以将所有标记放在同一行,但代码看起来不是很干净(如此JSFiddle所示) Browsers like to condense all whitespace into a single space when rendering (view this StackOverflow question ... -
有很多方法可以实现这一点,但是您可能想要使用弹性盒,因为它现在已经被广泛使用。 检查caniuse ,看它是否符合您的浏览器要求。 标记:Autofill remaining width200px
-
在div之后填补所有空间(To fill all space after div)[2023-06-18]
在css3中使用calc()属性: #right{ width: calc(100% - 100px); /*<---do it here*/ background: grey; position: relative; top:0; right: 0; height: 100px; } 不确定,但您也可以使用table, table-row, table-cell display属性来执行此操作: #wrap { border: 5px solid green; float: le ...