Jeremy Wright sets sail to uncharted waters

Jeremy Wright publicly announced today that he has has left the helm of b5media.

My family owes a lot to Jeremy Wright. With Aaron Brazell, Jeremy brought me into b5media, full time in this world of new media.

I’d not have made many of the friends I have today or traveled to some of the places I’ve been, without Jeremy and his dream for b5. He’s a good friend and a good man.

Times have not always been easy, but Jeremy has had the courage to make the difficult decisions that allowed my family and many others to still put food on the table. This is only due to Jeremy’s leadership and the strength of those at b5’s helm. Other companies in our market space have not been fortunate enough to have the same caliber of leadership.

Thank you for all the hard work over the years Jeremy, from all of us.

How do you get the current directory name in PHP?

I ran into a situation where I wanted to get the name of the directory I was in, in PHP. To be clear, I didn’t want the full path, just the directory/folder name

To be clear, if I was working in the directory:
/home/username/public_html/addonname

I wanted to have addonname returned.

I worked out two solutions.

The first solution used the getcwd() function which returns the full directory path as shown above but to use the basename function to get the part I needed. It worked so… “echo basename(getcwd());” returns “addonname” in this scenario.

That would meet my needs perfectly. I believe that matches my requirements in spirit, but was not literally correct. That statement returned the current working directory, but not the directory where the file was located. In fact, PHP 4 and PHP 5 differ when getcwd() is called from the command line. If you are in the ‘/’ directory and execute “php /test/talktome.php“, a php 4 getcwd() in that file will return the path “/test” while PHP 5 will correctly return ‘/’.

To resolve this, this next call works even better:
echo basename(dirname(__FILE__));

Does anyone want to do some speed tests to see which is faster after 10,000 calls? Let us know your results.