PHP ke JavaScript
$str = <<<MY_MARKER
<script type="text/javascript">
document.write("Hello World!");
</script>
MY_MARKER;
echo $str;
DeBugDeFrontPage
$str = <<<MY_MARKER
<script type="text/javascript">
document.write("Hello World!");
</script>
MY_MARKER;
echo $str;
public function getresultTree(array $elements, $parentId = 0) {
$branch = array();
foreach ($elements as $element) {
if ($element['parent_id'] == $parentId) {
$children = getresultTree($elements, $element['id']);
if ($children) {
$element['child'] = $children;
}
$branch[] = $element;
}
}
return $branch;
<?php
ini_set("soap.wsdl_cache_enabled", 0); $url="https://www.paiementpro.net/webservice/OnlineServicePayment_v2.php?wsdl"; $client = new SoapClient($url,array('cache_wsdl' => WSDL_CACHE_NONE)); $array=array( 'merchantId'=>'PP-F105',
'countryCurrencyCode'=>'952',
'amount'=>1000,
'customerId'=>1,
'channel'=>'CARD',
'customerEmail'=>'[email protected]',
'customerFirstName'=>'Thierry',
'customerLastname'=>'Narcisse',
'customerPhoneNumber'=>'22507517917', 'referenceNumber'=>'878AABCDEFZ'.time(), 'notificationURL'=>'http://test.ci/notification/',
'returnURL'=>'http://test.ci/return/',
'description'=>'achat en ligne',
'returnContext'=>'test=2&ok=1&oui=2',
);
try{ $response=$client->initTransact($array);
if($response->Code==0){ //var_dump($response->Sessionid);die();
header("Location:https://www.paiementpro.net/webservice/onlinepayment/processing_v 2.php?sessionid=".$response->Sessionid);
} }
catch(Exception $e) {
echo $e->getMessage(); }
?>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$str = "JOHN";
$str1 = "SMITH";
if(strlen($str) >= strlen($str1)){
$strtoloop = $str;
}else{
$strtoloop = $str1;
}
$i = 0;
$mergestring = '';
while($i < strlen($strtoloop)){
if($i < strlen($str))
$mergestring .= $str[$i];
if($i < strlen($str1))
$mergestring .= $str1[$i];
$i++;
}
echo $mergestring;
function calculateTheDistance ($lt1, $lng1, $lt2, $lng2) {
// перевести координаты в радианы
$lat1 = $lt1 * M_PI / 180;
$lat2 = $lt2 * M_PI / 180;
$long1 = $lng1 * M_PI / 180;
$long2 = $lng2 * M_PI / 180;
// косинусы и синусы широт и разницы долгот
$cl1 = cos($lat1);
$cl2 = cos($lat2);
$sl1 = sin($lat1);
$sl2 = sin($lat2);
$delta = $long2 - $long1;
$cdelta = cos($delta);
$sdelta = sin($delta);
// вычисления длины большого круга
$y = sqrt(pow($cl2 * $sdelta, 2) + pow($cl1 * $sl2 - $sl1 * $cl2 * $cdelta, 2));
$x = $sl1 * $sl2 + $cl1 * $cl2 * $cdelta;
//
$ad = atan2($y, $x);
$dist = $ad * EARTH_RADIUS;
$k = 40 / $dist;
$Xc = $lt1 + ($lt2 - $lt1) * $k;
$Yc = $lng1 + ($lng2 - $lng1) * $k;
$full = [$Xc , $Yc];
// echo "<br>";
// var_dump($full);
// echo "<br>";
return $full;
}
function high_order_bitmask($wordSize) {
if($wordSize == 0 or $wordSize == 1){
return 0;
}
$bitmask = 0;
for($i=$wordSize-1; $i >= $wordSize/2; $i-- ){
$bitmask += pow(2,$i);
}
return $bitmask;
}