Jump to content

CLI Server/Browscap Problem


paulmo

Recommended Posts

Downloaded php_browscap.ini as instructed in php docs, and put php_browscap.ini in /var/www directory where my php scripts live. then I changed path in /usr/share/php5/php.ini-production from browscap = extra/browscap.ini to

;browscap = /var/www/php_browscap.ini

...and get error message in terminal:

PHP Notice: Undefined index: HTTP_USER_AGENT in /var/www/test.php on line 2PHP Warning: get_browser(): browscap ini directive not set in /var/www/test.php on line 4
tried with and without commented ";" tag in .ini file, still get error. so, cli php works but not cli server. script works in browser with apache2, but I'd like to get cli server going for development...
<?phpecho $_SERVER['HTTP_USER_AGENT'] . "\n\n"; $browser = get_browser(null, true);print_r($browser);?>

wondering, does /usr/share/php5/php.ini-production need to be in /var/www? should I not be putting my php scripts in /var/www, and instead put them in (and point apache2 to) /usr/share/php5?? just guessing at this point. thanks in advance for help.

Link to comment
Share on other sites

thanks for reply James, browscap problem seems to be fixed after editing /etc/php5/cli/php.ini to point to /var/www directory. But the web server (cli terminal server not apache) is now my problem...here are php web server instructions:

Example #1 Starting the web server $ cd ~/public_html$ php -S localhost:8000 The terminal will show: PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011Listening on localhost:8000Document root is /home/me/public_htmlPress Ctrl-C to quit
but I don't get that...I get php cli usage instructions. also, there is no /public_html directory on my machine, so I've tried cd /var/www, and localhost:80...neither helps. when I run script in terminal I get:
get_browser(): HTTP_USER_AGENT variable is not set, or Undefined index: HTTP_USER_AGENT
with either get_browser or $_SERVER[HTTP...etc. scripts. ...would my apache2 config file, /etc/apache2/sites-available/default have anything to do with this?? edit: seems to do with my v. 5.3.3...server is only 5.4 yes?
Link to comment
Share on other sites

When you run PHP from a command line there is no browser, no HTTP headers are sent and several other things are not available which are available in a web server environment. http://php.net/manual/en/features.commandline.differences.php And yes, the development server is only available as of PHP 5.4.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...