if (extension_loaded('newrelic')) {
newrelic_set_appname (name);
}
<VirtualHost 192.168.0.11> ServerName www.myvhost1.tld DocumentRoot "/path/to/vhost1/" <IfModule PHP_MODULE> php_value newrelic.appname "Application 1" </IfModule> </VirtualHost> <VirtualHost 192.168.0.12> ServerName www.myvhost2.tld DocumentRoot "/path/to/vhost2/" <IfModule PHP_MODULE> php_value newrelic.appname "Application 2" </IfModule> </VirtualHost>
The upgrade from Debian 8.10 to 9.3 involved upgrading to PHP7.0. After that, I got an error from a web application saying : "Can not connect to database. Make sure the 'mysqli' extension is enabled" SOLUTION : apt install php7.0-cgi php-mysql systemctl restart lighttpd SOURCE : https://stackoverflow.com/questions/35424982/how-to-enable-mysqli-extension-in-php-7 VALUES RETURNED BY phpinfo() : Configuration File (php.ini) Path /etc/php/7.0/cgi Loaded Configuration File /etc/php/7.0/cgi/php.ini ===================================================================================================== 2017-12-13 11:31:10: (mod_fastcgi.c.2543) FastCGI-stderr: PHP Fatal error: Uncaught Error: Call to undefined function utf8_encode() in /var/www/xxxxxxxx/index.php:552 SOLUTION : apt install php7.0-xml && systemctl restart lighttpd SOURCE : https://stackoverflow.com/questions/35701730/utf8-endecode-removed-from-php7#answer-36902105
deb http://packages.dotdeb.org jessie all deb-src http://packages.dotdeb.org jessie all
short_open_tag
bug php_flag log_errors on php_value error_log /path/to/php_errors.log
<?php $newDomainName = 'new.example.tld'; header( "Location: http://$newDomainName".$_SERVER['REQUEST_URI'], True, 301 );
<?php $from = 'test@domain.tld'; you can put anything here $to = 'john.smith@gmail.com'; $subject = 'This is the subject'; $message = 'Hello World !'; $headers = "From: $from\r\n" . "Reply-To: $from\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($to, $subject, $message, $headers)) { print "Mail sent\n"; } else { print "Ooops\n"; }
<?php $dbHost = 'myServer'; $dbName = 'myDatabase'; $dbUser = 'user'; $dbPassword = 'password'; $dbTable = 'myTable'; $dsn = sprintf("mysql:dbname=$dbName;host=$dbHost"); $driverOptions = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'); $dbConnection = new PDO($dsn, $dbUser, $dbPassword, $driverOptions); $sql = "select count(1) from $dbTable;"; $resultSet = $dbConnection->query($sql); foreach($resultSet as $result) { print("$result[0]\n"); }
For complete details on PHP configuration, you can create a short PHP file containing :
<?php phpinfo(); ?>and read its result with any web browser.
<?php phpinfo(); ?>
' | php , then grep / > / ...phpinfo();
" : (-r/--run : run specified code)echo(ini_get("memory_limit"))."\n";
'phpinfo();
' | grep -i sslphp -m
Xdebug should appear twice : once under PHP Modules and once under Zend Modules (source).
trigger_error('ARGL !', E_USER_NOTICE)
ini_set('log_errors', 'off'); ini_set('display_errors', 'on');
ini_set('log_errors', 'on'); ini_set('error_log', '/path/to/logFile.log');
/path/to/logFile.log must be writable by the web server's user.
$_SERVER['SERVER_NAME'] (explicit) is supposed to handle the "server name", but this name can have several values. It is possible to tune Apache to control which value is affected to this variable.
This is done by editing /etc/httpd/conf/httpd.conf and change the value of the parameter UseCanonicalName :
Value | Output | Example |
---|---|---|
Off | IP address | 12.34.56.78 |
On | system hostname | myServer |
Dns | system DNS name | myServer.myCompany.tld |
$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT']
is equivalent to $_SERVER['HTTP_HOST']
oci_connect()
, but these functions are defined in the Oracle client libraries. Follow this procedure to install these libraries. Basically, you have to :
PHP Parse error: syntax error, unexpected end of file in /path/to/file.php on line 294
Parse error: syntax error, unexpected $end in /path/to/file.php on line 84
right PHP syntax | short_open_tag = On | short_open_tag = Off |
---|---|---|
<?=myVariable?> |
<?php echo(myVariable); ?> |
|
<? your PHP code ?> |
<?php your PHP code ?> |
/^short_open_tag =.*$/ s/Off/On/
' "$phpIniFile" && systemctl restart apache2After that, make sure you have only short open tags (<?
, but no <?php
) in your code, otherwise the error may still occur.