什么是PhP的好呐喊

Sha*_*yrs 9 php no-op

有时候我不想做任何事情.

我只是想发表一个声明,这样我才能提出突破点.

在c和objective-c中我们有while(false);

说我想打破一个功能

-(void)viewDidAppear:(BOOL)animated
{

    [super viewDidAppear:animated];
    self.navigationItem.leftBarButtonItem=nil;
    self.navigationItem.rightBarButtonItem=nil;


    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(updateDisplays) name: NotificationUpdateArroworLocation object:nil];

    PO(self.tableView.indexPathForSelectedRow);
    while(false);//I put break point here so program stop here.
}
Run Code Online (Sandbox Code Playgroud)

在.net中我们没有什么(不确定我是否做到了?).

我们应该在PhP中使用什么?

Ale*_*lex 13

您可以使用相同的技巧和许多其他功能:

<?php
    while (false);
    // or empty output
    echo '';
    // or any expression without side effects
    5 + 5;
Run Code Online (Sandbox Code Playgroud)

如果使用XDebug,可以直接在任何地方调用xdebug_break()函数.


Ric*_*ing 8

assert(true);
Run Code Online (Sandbox Code Playgroud)

足以附加一个断点?

对于dev环境,应该编译和执行断言.对于prod环境,可能不应编译或执行断言.所以你可以让他们进去.这很有用!

http://www.php.net/manual/en/function.assert.php