Asked  2 Years ago    Answers:  5   Viewed   57 times

I have a php application that is installed on several servers and all of our developers laptops. I need a fast and reliable way to get the server's hostname or some other unique and reliable system identifier. Here's what we have thought of so far:

<? $hostname = (!empty($_ENV["HOSTNAME"])) ? $_ENV["HOSTNAME"] : env('HOSTNAME'); ?>

<? $hostname = gethostbyaddr($_SERVER['SERVER_ADDR']); ?>

<? $hostname = exec('hostname'); ?>

What do you think?



What about gethostname()?

Edit: This might not be an option I suppose, depending on your environment. It's new in PHP 5.3. php_uname('n') might work as an alternative.

Thursday, December 15, 2022

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Sunday, July 31, 2022
  • It should add p-tags instead of line break like.

Run it through something like the Textile interpreter, or Markdown, or any another humane markup language which suits your needs.

  • It should remove empty space like tripple spaces
  • It should remove double line breaks.
  • It should remove tabs.
  • It should remove line breaks and spaces before the content if any.
  • It should remove line breaks and spaces after the content if any.

Why bother? When HTML is rendered as a document, multiple white space characters are reduced to a single space, no? Most of your problems solve themselves.

Friday, October 21, 2022

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Sunday, November 6, 2022

Whenever I need the context in a form, I'm doing it via constructor injection.

in the action:

$this->form = new WhateverForm($whatever, array("context" => $this->getContext()));

in the form:

Sunday, October 23, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages