PHP CORS Cross Origin access control allow origin example html
CORS-Cross-Origin-Resource-Sharing Header set Access-Control-Allow-Origin Source Code Example
Usefull Links here
https://www.w3.org/wiki/CORS_EnabledApache .htaccess Allow File Types
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch ".(bmp|cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
.htaccess which is closest to the file!!!!!
Date: 17.06.2020 - 08:0977LW NO topic_id
AD
Další témata ....(Topics)
For all browsers e.g. old IE 11 ....
<script>
var mbThreadOneRunning = false;
var mbThreadOneEnded = false;
var mbThreadTwoRunning = false;
var mbThreadTwoEnded = false;
// you can create more than one Thread
// setTimeout() used for running more Threads at once
var timeout_1 = setTimeout("ThreadOne()", 5000); // 5000 == 5 second
var timeout_2 = setTimeout("ThreadTwo()", 3000); //
function ThreadOne() {
mbThreadOneRunning = true;
alert("1. ThreadOne working!");
// working code here .............
mbThreadOneEnded = true;
clearTimeout(timeout_1);
}
function ThreadTwo() {
mbThreadTwoRunning = true;
alert("2. ThreadTwo working!");
// working code here .............
mbThreadTwoEnded = true;
clearTimeout(timeout_2);
}
var mInterval = setInterval("checkThread()", 1000); // 1000 ms == 1 second, you can put smaller value
function checkThread() {
if (mbThreadOneEnded == true) {
alert("1. checkThread() ThreadOne finish work! " + mbThreadOneEnded);
}
else if (mbThreadTwoEnded == true) {
alert("2. checkThread() ThreadTwo finish work! " + mbThreadTwoEnded);
}
if (mbThreadOneEnded && mbThreadTwoEnded) {
clearInterval(mInterval); // just to be sure
mbThreadOneEnded = false;
mbThreadTwoEnded = false;
alert("ThreadOne and ThreadTwo ended ");
}
}
</script>
php bývá vyčítano, že proměnné jsou typově nejednoznačné. To je sice pravda, ale php má funkci, která vrátí typ proměnné v dané části kodu.
$var = 10;
// funkce gettype vrací retezec s nazvem typu
// tak, jak jej vydi prekladac pri linkovani kodu
$s = gettype($var); // $s == 'integer'
$var = 'some text';
$s = gettype($var); // $s == 'string'
$var = 10.1;
$s = gettype($var); // $s == 'double'
Jak zjistit v javascriptu zda objekt existuje
How test if an object exists undefined or null.
if (typeof OBJECT_NAME != "undefined") {
//object exists ... execute code here.
}
// or best of use try catch
var nObject;
try{
nObject = image.image; // is image.image object?
}catch (e){
alert(e.message.toString()); // e.message == 'undefined' is null or not an object
return; // or continue if image.image is a object
}
// you can test now nObject as typeof nObject
if(typeof nObject == 'string') // or others etc.
{
// do something
}
// dont use this
if (OBJECT_NAME != null) {
//if object dont exists will error
}
Multi-byte UNICODE PHP.
Pokud pracujete s diakritikou budou se Vám hodit funkce, které začínají mb_ tedy multi-byte funkce.Abyste nemuseli do každé funkce udávat kódování viz příklad
$mbLen = mb_strlen('žluťoučký','utf-8');
přidávejte na začátek kódu internal encoding
mb_internal_encoding('utf-8');
$mbLen = mb_strlen('žluťoučký');
Příklad si vyzkoušejte a ověřte hodnoty $mbLenLetní čas tak připočítat hodinu.
Ověření zda je letní čas.
$dst = date("I"); //I (capital i); 0 or 1 if daylight saving time
// example:
$hour = 14;
if(date("I")===1){
$hour = $hour + 1;
}
// OR
$hour = 14 + date("I");
Editace: 17.6.2020 - 12:56
Počet článků v kategorii: 77
Url:php-cors-cross-origin-access-control-allow-origin-example-html