What is the best approach to check php version 8.1 and to upgrade in 8.2 the function.
var_dump(phpversion()); ==> 8.1.7-1ubuntu3.2
var_dump((float)phpversion()); ==> 8.1
thank you
There are some builtin constants that may be easier to use as they are not messed about with by per OS compilations
echo 'PHP_MAJOR_VERSION = ' . PHP_MAJOR_VERSION . PHP_EOL;
echo 'PHP_MINOR_VERSION = ' . PHP_MINOR_VERSION . PHP_EOL;
echo 'PHP_RELEASE_VERSION = ' . PHP_RELEASE_VERSION . PHP_EOL;
RESULT
My current version of PHP 8.2.1
PHP_MAJOR_VERSION = 8
PHP_MINOR_VERSION = 2
PHP_RELEASE_VERSION = 1
Related
i have tried installing phpmyadmin on arch linux but every time i open localhost/phpmyadmin,i get this text.
PHP 7.2.5+ is required.
Currently installed version is: ' . PHP_VERSION . '
'); } // phpcs:disable PSR1.Files.SideEffects define('PHPMYADMIN', true); // phpcs:enable require_once ROOT_PATH . 'libraries/constants.php'; /** * Activate autoloader */ if (! #is_readable(AUTOLOAD_FILE)) { die( '
File ' . AUTOLOAD_FILE . ' missing or not readable.
' . '
Most likely you did not run Composer to ' . '' . 'install library files.
' ); } require AUTOLOAD_FILE; global $route, $containerBuilder, $request; Common::run(); $dispatcher = Routing::getDispatcher(); Routing::callControllerForRoute($request, $route, $dispatcher, $containerBuilder);
i have installed php and this its version
PHP 8.1.8 (cli) (built: Jul 9 2022 06:10:37) (NTS)
i have also tried following all the steps in arch documentation (https://wiki.archlinux.org/title/phpMyAdmin)
but when i try to open the url(localhost/phpmyadmin),it outputs a blank page with no
body so i had to reset all the configs to default.help me out.thanks alot
to solve this issue,i reinstalled everything again,followed the steps in (https://wiki.archlinux.org/title/phpMyAdmin) and in /etc/php/php.ini,uncommented the extension 'bz2 and mysqli'
I have PHP v7.3 and I'm running the following PHP code, trying to create a password protected ZIP-file.
The ZIP-file is created, but it's not password protected. What could be wrong?
$zip = new ZipArchive();
$zipFile = $this->backupDir . '/' . $db_file_name . '_' . $this->backupFormat . '.sql.zip ';
if (file_exists($zipFile)) { unlink($zipFile); }
$zip->open($zipFile, ZipArchive::CREATE);
$password = 'top-secret';
$zip->setPassword($password);
$fileName = $this->backupDir . '/' . $db_file_name . '.sql';
$baseName = basename($fileName);
$zip->addFile($fileName, $baseName);
$zip->setEncryptionName($fileName, ZipArchive::EM_AES_256);
$zip->close();
I'm not getting any errors. It's just that he generated ZIP-file is unprotected.
When checking out phpinfo, you see libzip version is used. This must be increased to version 1.2.0 or newer.
I have experienced the same. I have tried it in many different ways but it didn't work for me under Linux using PHP 8.0. I have tried it on 2 different linux servers.
Libzip is installed and the recommended (1.2.x) version is used.
At the end I used the other way that is recommended by many other developers:
<?php
$password = 'get the password by some secure way';
$zipFileName = sprintf('compressed_file--%s-%s.zip', (new DateTime('now'))->format('Y-m-d'), mt_rand(0, 99999));
$zipFilePath = sys_get_temp_dir() . '/' . $zipFileName;
$contentFilePath = 'some_file_prepared_in_tmp_folder.xls';
system('cd /tmp; zip -P ' . $password . ' ' . $zipFilePath . ' ' . $contentFilePath);
?>
I am using wamp and 5.5.12 php version
Download php_ffmpeg.dll from somewhere and copied in C:\wamp\bin\php\php5.5.12\ext
restarted wamp and computer as well.
but it says php_ffmpeg.dll is missing any help ?
I am using 64bit system any offical place to look for php_ffmpeg.dll 64bit version
?
the code:
/**
* FFMPEG-PHP Test Script
*
*/
echo "GD: ", extension_loaded('gd') ? 'OK' : 'MISSING', '<br>';
echo "XML: ", extension_loaded('xml') ? 'OK' : 'MISSING', '<br>';
echo "zip: ", extension_loaded('zip') ? 'OK' : 'MISSING', '<br>';
echo "ffmpeg: ", extension_loaded('ffmpeg') ? 'OK' : 'MISSING', '<br>';
// Check if the ffmpeg-php extension is loaded first
// extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
// Determine the full path for our video
// $vid = realpath('./vid2.avi');
$vid = realpath('input.flv');
// d then display the information about the video clip.
$ffmpegInstance = new ffmpeg_movie($vid);
echo "getDuration: " . $ffmpegInstance->getDuration() . "<br />".
"getFrameCount: " . $ffmpegInstance->getFrameCount() . "<br />".
"getFrameRate: " . $ffmpegInstance->getFrameRate() . "<br />".
"getFilename: " . $ffmpegInstance->getFilename() . "<br />".
"getComment: " . $ffmpegInstance->getComment() . "<br />".
"getTitle: " . $ffmpegInstance->getTitle() . "<br />".
"getAuthor: " . $ffmpegInstance->getAuthor() . "<br />".
"getCopyright: " . $ffmpegInstance->getCopyright() . "<br />".
"hasAudio: " . $ffmpegInstance->hasAudio();
Putting a compiled PHP extension in the extension directory is not sufficient. Additionally, the extension has to be declared in php.ini extension directive, e.g. extension=php_ffmpeg.dll.
I am using 64bit system any offical place to look for php_ffmpeg.dll 64bit version ?
There is http://ffmpeg-php.sourceforge.net/, but this project is abandoned, so you're probably out of luck. See https://trac.ffmpeg.org/wiki/PHP for alternative ways to use ffmepg from PHP.
I'm trying the PEAR Net_Nmap package from here:
https://pear.php.net/package/Net_Nmap/
I have Nmap installed on my Windows 10 machine.
I found the following code that should do the job.
Is there something I should configure before I use PEAR?
I'm getting 2 errors:
Warning: require_once(XML/Parser.php): failed to open stream: No such file or directory in C:\xampp\htdocs\Net_Nmap-master\Net\Nmap\Parser.php on line 31
Fatal error: require_once(): Failed opening required 'XML/Parser.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Net_Nmap-master\Net\Nmap\Parser.php on line 31
<?php
// Scan network to retrieve hosts and services information.
require_once 'Net/Nmap.php';
//Define the target and options
$target = array('193.95.13.16','www.google.com');
$options = array('nmap_binary' => 'C:\Program Files (x86)\Nmap');
try {
$nmap = new Net_Nmap($options);
$nmap_options = array(
'os_detection' => true,
'service_info' => true,
'port_ranges' => 'U:53,111,137,T:21-25,80,139,8080',
// Only specified ports
);
$nmap->enableOptions($nmap_options);
// Scan
$res = $nmap->scan($target);
// Get failed hosts
$failed_to_resolve = $nmap->getFailedToResolveHosts();
if (count($failed_to_resolve) > 0) {
echo 'Failed to resolve given hostname/IP: ' .
implode (', ', $failed_to_resolve) .
"\n";
}
//Parse XML Output to retrieve Hosts Object
$hosts = $nmap->parseXMLOutput();
//Print results
foreach ($hosts as $key => $host) {
echo 'Hostname: ' . $host->getHostname() . "\n";
echo 'Address: ' . $host->getAddress() . "\n";
echo 'OS: ' . $host->getOS() . "\n";
echo 'Status: ' . $host->getStatus . "\n";
$services = $host->getServices();
echo 'Number of discovered services: ' . count($services) . "\n";
foreach ($services as $key => $service) {
echo "\n";
echo 'Service Name: ' . $service->name . "\n";
echo 'Port: ' . $service->port . "\n";
echo 'Protocol: ' . $service->protocol . "\n";
echo 'Product information: ' . $service->product . "\n";
echo 'Product version: ' . $service->version . "\n";
echo 'Product additional info: ' . $service->extrainfo . "\n";
}
}
}
catch (Net_Nmap_Exception $ne) {
echo $ne->getMessage();
}
?>
You did not use the PEAR installer to install the net_nmap package, but probably downloaded the .tgz file and extracted it.
Now you are missing the dependencies which are listed on the bottom left of the Net_NMap page. Install them.
I am successfully starting and running concurrent PHP-Processes with:
$WshShell = new COM('WScript.Shell');
foreach(array('foo', 'bar', ...) as $i) {
$oExec = $WshShell->Run('C:\\wamp\\bin\\php\\php' . phpversion() . '\\php.exe ' .
'-c C:\\wamp\\bin\\apache\\Apache2.2.21\\bin ' . // Use correct php.ini!
'-f C:\\Users\\Max\\Project\\start.php "' . $i . '" ' . 0, false);
}
}
I am wondering how many PHP-Processes I can run at the same Time (in a usual Windows and Linux Environment)?