Posted on November 27, 2019, 11:27 pm, by admin, under
mysql,
php.
<?php $dbname = ‘dbname’; $dbuser = ‘user’; $dbpass = ‘pass’; $dbhost = ‘hostname’; $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to ‘$dbhost’"); mysql_select_db($dbname) or die("Could not open the db ‘$dbname’"); $test_query = "SELECT 1,2,3,4 FROM yourtable"; $result = mysql_query($test_query); $tblCnt = 0; while($tbl = mysql_fetch_array($result)) { $tblCnt++; echo $tbl[0]."<br />\n"; echo […]
Posted on November 15, 2019, 1:09 pm, by admin, under
php.
function getNearestMatch($number, $candidates) { $candidates = is_array($candidates) ? $candidates : array($candidates); $size = count($candidates); if ($size > 0) { //absolute difference between 0th element and input value $diff = abs($candidates[0] – $number); //element closest to input value $ret = $candidates[0]; //loop through the rest of the array for ($i = 1; $i < […]
Posted on October 22, 2019, 10:30 am, by admin, under
php.
<?php class Rates { function Convert($amount,$from,$to){ $url="http://adsynth-ofx-quotewidget-prod.herokuapp.com/api/1"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ‘{"method":"spotRateHistory","data":{"base":"’.$from.’","term":"’.$to.’","period":"week"}}’); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array(’Content-Type:application/json’)); curl_setopt($ch, CURLOPT_REFERER, "https://widget-yahoo.ofx.com/"); $html = curl_exec ($ch); curl_close ($ch); $veri=json_decode($html,true); return $veri["data"]["CurrentInterbankRate"]*$amount; } } $kur = new Rates(); echo $kur->Convert(1, ‘USD’, ‘GBP’);
Associative arrays in PHP = Javascript Objects written as name value pairs = Hash maps in Java
Posted on July 15, 2019, 2:37 pm, by admin, under
php.
echo preg_replace("/[\W]/u", "", $str);
Posted on May 28, 2019, 2:51 pm, by admin, under
php.
if(preg_match(’/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/’,$datetime)) { echo "correct"; }
Posted on May 2, 2019, 2:27 pm, by admin, under
php.
Yes. Independently from the platform PHP is running on, the scripts are compiled into the same bytecode and run by the Zend Engine. The difference from Java is that this compiled code is usually not stored into separate files and the scripts are re-compiled on each execution (however, see opcode caches). Another important difference between […]
Posted on April 18, 2019, 8:28 am, by admin, under
php.
In short, in case of full abstraction of methods you want to define use interface, in case of partial abstraction, if some methods you want to define are common among concrete classes but some are not then use abstract class Abstract class can have definitions of constants, abstract methods or method stubs (methods without body/implementation) […]
A1 Injection (PHP include, global variables, Sql Injection through Url) A2 Broken authentication (To avoid broken authentication put into practice not leaving the login page for admins publicly accessible. Rename /wp-admin/ on WordPress to something else. Rename /admin in Magento to something else) A3 Sensitive data exposure (arp spoofing resulting traffic sniffing, stealing auth passwords, […]
Posted on April 16, 2019, 3:48 pm, by admin, under
php.
Abstraction (Abstract classes and Interfaces) > Inheritance (class extends parent Abstract or concrete class). Encapsulation (blackbox, isolation methods, getters, setters, Creational Patterns) Polymorphism (overriding, logical cluster principle – many classes (nodes) on same level with diff implementation of same function (operation), Operational patterns, Strategy pattern) Inheritance – пожалуй, важнейшая особенность object based programming. Если требуется […]