php exec debugging no stdout and stderr output
try this exec(’some_unkown_command 2>&1′, $output); print_r($output);
try this exec(’some_unkown_command 2>&1′, $output); print_r($output);
$string=’ <?xml version="1.0" encoding="UTF-8"?> <products> <product category="software"> <sku>soft32323</sku> <name>Widget Reporting</name> <price>4550</price> </product> <product category="software"> <sku>soft32323</sku> <sub_category>Business Analysis</sub_category> <name>Pro Reporting</name> <price>2350</price> </product> </products>’; $xml = simplexml_load_string($string); // Search by tag name $products = $xml->xpath("/products/product[sku=’soft32323′]/name"); print_r($products); // Search by tag attribute $products = $xml->xpath("/products/product[@category=’software’ and price > 2320]"); print_r($products);
$ecbRates = simplexml_load_file("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"); $namespaces = $ecbRates->getDocNamespaces(); $ecbRates->registerXPathNamespace("ecb", $namespaces[”]); $array = $ecbRates->xpath("//ecb:Cube[@currency=’GBP’]/@rate"); echo (string) $array[0][’rate’];
<?php function convert($from,$to,$amount) { $url = "https://www.google.com/search?q=".$from.$to; $request = curl_init(); $timeOut = 0; curl_setopt ($request, CURLOPT_URL, $url); curl_setopt ($request, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($request, CURLOPT_USERAGENT,"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML , like Gecko) Chrome/68.0.3440.106 Safari/537.36"); curl_setopt ($request, CURLOPT_CONNECTTIMEOUT, $timeOut); $response = curl_exec($request); curl_close($request); preg_match(’~<span [^>]* id="knowledge-currency__tgt-amount"[^>]*>(.*?)</span>~si’, $response, $finalData); return floatval((floatval(preg_replace("/[^-0-9\.]/","", $finalData[1]))/100) […]
$file = ‘myimage.png’; $size = getimagesize($file); $fp = fopen($file, ‘rb’); if ($size and $fp) { header(’Content-Type: ‘.$size[’mime’]); header(’Content-Length: ‘.filesize($file)); fpassthru($fp); }
<?php define( ‘_JEXEC’, 1 ); define( ‘JPATH_BASE’, realpath(dirname(__FILE__).’/../../..’ )); define( ‘DS’, DIRECTORY_SEPARATOR ); require_once ( JPATH_BASE .DS.’includes’.DS.’defines.php’ ); require_once ( JPATH_BASE .DS.’includes’.DS.’framework.php’ ); $mainframe =& JFactory::getApplication(’administrator’); $mainframe->initialise(); $app =& JFactory::getApplication(); $user =& JFactory::getUser(); if($app->isAdmin() && !$user->id) { header(’Location: /administrator’); exit(); } ?>
The right ! will result in a boolean, regardless of the operand. Then the left ! will be applied to that boolean. It means if $row has a truthy value, it will return true, otherwise false, converting to a boolean value. It is equalent of casting to boolean as it convert anything to boolean. return […]
$data[’message’] = ‘Simple Message’; $data[’status’] = ‘success’; header(’Content-Type: application/json’); echo json_encode($data);
Abstract class – is something between a regular class and a pure interface. The purpose of this is to provide a kind of template to inherit from and to force the inheriting class to implement the abstract methods. Interface – is a special case of abstract classes where ALL methods are abstract.
<?php function memoryChecker($variable) { echo ‘in function: ‘.memory_get_usage()."\n"; } echo ‘before function: ‘.memory_get_usage()."\n"; $var = "hello world\n"; memoryChecker($var);