What would be nice for PhP

Sometimes I don’t want to do anything.

I just want to have instructions so that I can set a breakpoint.

In c and objective-c we have while (false);

Say I want to break a function

-(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. } 

At .net we have donothing (Not sure if I did this?).

What should we use in php?

+6
source share
2 answers

Would

 assert(true); 

enough to snap a breakpoint to?

For the dev environment, you need to compile and execute statements. For a prod environment, statements probably should not be compiled and executed. Therefore, you can leave them. What is useful!

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

+1
source

You can use the same trick and many other functions:

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

If you are using XDebug, you can call xdebug_break () directly from anywhere.

+11
source

All Articles