What is the preferred way of notating methods in comments?

Sometimes one has to refer to another method when commenting. Here some example in PHP: class A { /** * @see B::bar */ public function foo() { B::bar(); } } class B { public static function bar() { // ... } } So what if there would be a non-static method bar in class B ? What is the best way to name other methods in comments? Edit The

注释中注释方法的首选方式是什么?

有时在评论时必须引用另一种方法。 这里有一些PHP例子: class A { /** * @see B::bar */ public function foo() { B::bar(); } } class B { public static function bar() { // ... } } 那么,如果在B类中会有一个非静态的方法bar呢? 在评论中命名其他方法的最佳方式是什么? 编辑 PHP手册似乎使用mysqli->affected_rows以及PDO::beginTransaction 。 但

Convert array to an .ini file

I need to parse an .ini file into an array, and later change the values of the array and export it to the same .ini file. I managed to read the file, but didn't find any simple way to write it back. Any suggestions? Sample .ini file: 1 = 0; 2 = 1372240157; // timestamp. In order to write the .ini file back, you need to create your own function, for PHP offers no functions out of the

将数组转换为.ini文件

我需要将.ini文件解析为数组,然后更改数组的值并将其导出到相同的.ini文件。 我设法读取文件,但没有找到任何简单的方法来回写。 有什么建议么? 示例.ini文件: 1 = 0; 2 = 1372240157; // timestamp. 为了写入.ini文件,您需要创建自己的函数,因为除了阅读外,PHP不提供任何开箱即用的功能(可以在这里找到它:http://php.net/manual/pl/ function.parse-INI-file.php)。 可能将多维数组封装为.ini -syntax兼容

Dependency Injection / LoD

I understand the basic principles of dependency injection but would like some advice on how to handle classes instantiated within other classes methods; does this go against the dependency injection pattern? Moreover, I would like to write the object (class) to a DB (mongo in object form) and so don't want it to be bloated with other dependencies. To better explain what I mean here is an

依赖注入/ LoD

我理解依赖注入的基本原则,但希望了解如何处理其他类方法中实例化的类; 这是否违背了依赖注入模式? 此外,我想写对象(类)到数据库(对象形式的mongo),所以不希望它与其他依赖关系臃肿。 为了更好地解释我在这里的意思是一个例子: 假设我们有一个用服务器类注入的用户类 - class User{ public $user_id public $user_name; public function __construct(server $server){ $this->server =

How to use PHP classes between other classes

This question already has an answer here: What is dependency injection? 31 answers Declare the function printStatus as static: static function printStatus($text, $html = true) You can call this function by using "::", formatOutput::printStatus("hello");

如何在其他类之间使用PHP类

这个问题在这里已经有了答案: 什么是依赖注入? 31个答案 将函数printStatus声明为static: static function printStatus($text, $html = true) 你可以使用“::”来调用这个函数, formatOutput::printStatus("hello");

importance of Interfaces and Abstract Classes in PHP

This question already has an answer here: What is dependency injection? 31 answers Defining both interfaces and abstract classes are design mechanisms that help create solid software architectures. It doesn't have to do with security. They provide the ability create classes that best capture the real-world situation in which the software is trying to achieve. Why is it that some meth

PHP中接口和抽象类的重要性

这个问题在这里已经有了答案: 什么是依赖注入? 31个答案 定义接口和抽象类是帮助创建可靠软件体系结构的设计机制。 它不必与安全有关。 他们提供创建类的能力,以最好地捕捉软件试图实现的真实世界的情况。 为什么有些方法需要先将实例化Interfaces和Abstract Classes的对象先传递给普通类,然后才能直接将其添加到普通类中? 这是否代表您的代码的安全性? 这些都是代码开发人员的所有架构选择,并且与依赖注入相

Explanation Dependency Injection

This question already has an answer here: What is dependency injection? 31 answers 1 When should I use dependency injection? You should use dependency injection when you want to have control over which dependencies you class/method will use at runtime. The best example of this is when you might want to replace a dependency that accesses a database with one that uses memory for unit testin

解释依赖注入

这个问题在这里已经有了答案: 什么是依赖注入? 31个答案 1什么时候应该使用依赖注入? 当您想要控制您的类/方法在运行时使用哪些依赖关系时,应该使用依赖注入。 最好的例子就是当你可能想用一个为了单元测试目的而使用内存的访问数据库的依赖。 2为什么我应该使用它? 它使您的代码更易于测试,更灵活,更具可扩展性。 3它有哪些简单的词汇? 它是如何工作的? 它通常通过将依赖关系作为参数传递给方法或类

How to log dimension like AWS CloudWatch bundled metric

Can anyone explain how to use the AWS PHP SDK to log the metric in the style like the above screen. I use the following PHP code but the select menu is showing " ELB: AvaliabiltyZone ", how to make it show " Aggregated by AvaliabiltyZone "? What is the logic used here? $response = $cw->put_metric_data("ELB", array( array( "MetricName" => "Latency",

如何记录AWS CloudWatch捆绑的度量标准

任何人都可以解释如何使用AWS PHP SDK以上述屏幕样式记录度量标准。 我使用下面的PHP代码,但选择菜单显示“ ELB:AvaliabiltyZone ”,如何使它显示“ 由AvaliabiltyZone聚合 ”? 这里使用的逻辑是什么? $response = $cw->put_metric_data("ELB", array( array( "MetricName" => "Latency", "Dimensions" => array( array("Name" => "AvaliabiltyZone" , "Value" =>

Separate frontend and backend with Yii framework

用Yii框架分离前端和后端的最好和最正确的方法是什么? There's no offical way to do this in Yii 1.x, but there are several approaches. Have a look at yiinitializer advanced, to get an impression how frontend and backend are separated here. They are more or less two applications sharing a common folder. My project Phundament takes a simpler approach, just by switching themes depending on con

使用Yii框架分离前端和后端

用Yii框架分离前端和后端的最好和最正确的方法是什么? 在Yii 1.x中没有官方的方式来做到这一点,但有几种方法。 看看先进的yiinitializer,了解frontend和backend如何在这里分离。 它们或多或少是两个共享一个common文件夹的应用程序。 我的项目Phundament采用更简单的方法,只需通过多主题扩展根据控制器路线切换主题即可。 在这里看到漂亮的文章http://habrahabr.ru/post/117457/。 英文版本在这里提供:http://www.

How to create a regex that will match regardless of the sequence of characters?

Say I am requiring a user to input the certain words provided and he/will just input it on a textbox which will be validated regardless of order.I have been looking for answers for hours and I'm stuck :/ eg the words should be inputted are: foo, bar, green. and I can still match it even if the order is bar green foo or green foo bar I pretty much know the very basics of regex but I don&

无论字符序列如何创建匹配的正则表达式?

假设我要求用户输入提供的某些单词,他/她只会将它输入到一个文本框中,该文本框将被验证, 而不管其顺序如何 。我一直在寻找几个小时的答案,我被卡住了:/ 例如,应该输入的单词是:foo,bar,green。 即使订单是酒吧绿色foo或绿色酒吧 ,我仍然可以匹配它 我非常了解正则表达式的基础知识,但我不知道如何匹配这种类型的条件。任何答案都将非常感谢! 这会检查输入中是否有这三个单词,而不是更多: /^(?=.*bbarb)(?=.*

replace all links in file

This question already has an answer here: Regular expression to match a line that doesn't contain a word? 25 answers Try ~<a href="(.(?!remedy))*?".*?>(.*?)</a>~i To the question, what you are doing wrong: Regexes match ever if anyhow possible and for each url (even that containing remedy ) it is possible to match '~<a href=".*?(?!remedy).*?".*?&g

替换文件中的所有链接

这个问题在这里已经有了答案: 正则表达式匹配不包含单词的行吗? 25个答案 尝试~<a href="(.(?!remedy))*?".*?>(.*?)</a>~i 对于这个问题,你在做什么错误:正则表达式匹配永远如果有可能和每个URL(甚至包含remedy )可以匹配'~<a href=".*?(?!remedy).*?".*?>(.*?)</a>~i'因为您没有指定remedy可能不包含在属性中的任何位置,但是您指定了必须有任何/没有( .*?