PHP get variable type php
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'
77LW NO topic_id
AD
Další témata ....(Topics)
$country[0] = "cz"
$country[1] = "sk"
$country[2] = "de"
$country[3] = "uk"
$country[4] = "fr"
// this do same
$country[] = "cz"
$country[] = "sk"
$country[] = "de"
$country[] = "uk"
$country[] = "fr"
// or
$country = array('cz','sk','de','uk','fr');
// get array items count
$length = count($country);
for($i=0;$i<$length;$i++){
print $country[$i].'<br>';// cz sk de uk fr
}
// or like this
$country[50] = 'ca';
$country[10] = 'fr';
$country[20] = 'us'
// now country will index 51
$country[] = 'ru';
// or
$country = array('5'=>'cz','sk','de','uk','fr');
/*
Array
(
[5] => cz
[6] => sk
[7] => de
[8] => uk
[9] => fr
)
*/
// you can do this
$country["cz"] = 1571;
$country["sk"] = 1572;
$country["de"] = 1573;
$country["uk"] = 1574;
$country["fr"] = 1575;
print $country["uk"]; // 1574
// print all items key and value
foreach ($country as $key => $value){
print $key; // cz, sk, de, uk, fr
print $value; // 1571, 1572, 1573, 1574, 1575
}
Jak zabránit kopírování textu stránky v prohlížeči.
Do tagu body vložíme následující eventy:
oncontextmenu="return false" onmousedown="return false" onselectstart="return false" ondragstart="return false"
Tag body by mohl vypadat následovně:
<body oncontextmenu="return false" onmousedown="return false" onselectstart="return false" ondragstart="return false">
Funkce JavaScript pro práci s datumem a časem.
function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
}
// console.log(msToTime(300000))
// output: 00:05:00.0
// get time difference between two dates in seconds
var startDate = new Date();
// Do your operations
var endDate = new Date();
var seconds = (endDate.getTime() - startDate.getTime()) / 1000;
var milliseconds = (endDate.getTime() - startDate.getTime());
[, OPTIONAL second param [, OPTIONAL ... param]]
static Date.now() // returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
parse(dateVal) // Date.parse('05 Dec 1998 00:12:00 GMT'); // return 912816720000
toDateString() // sunday 19.7.2020
toTimeString() // 20:15:37
getDate() // 1-31
getDay() // 0-6, 0 == Sunday
var now = new Date();
var dayOfWeekSundayIs7 = now.getDay() == 0)?7:now.getDay();
getFullYear() // 2020
getHours() // 0-23
getMilliseconds() // eg. 956
getMinutes() // 0-59
getMonth() // 0 january
getSeconds() // 0-59
getTime() // https://en.wikipedia.org/wiki/Unix_time
getTimezoneOffset() //returns the time zone difference, in minutes, from current locale
getYear() //does not return full years ("year 2000 problem"), it is no longer used and has been replaced by the getFullYear() method.
setDate(numDate) // 1-31 day of month
setHours(numHours[, numMin[, numSec[, numMilli]]]) // now.setHours(20, 21, 22); 20:21:22
setMilliseconds(numMilli) // 0-999
setMinutes(numMinutes[, numSeconds[, numMilli]]) // 0-59, 0-59, 0-999
setMonth(numMonth[, dateVal]) // 0-11
setSeconds(numSeconds[, numMilli]) 0-59 [, 0-999]
setYear(numYear) // not set full years ("year 2000 problem"), it is no longer used and has been replaced by the setFullYear() method.
setUTCDate() //
setUTCFullYear(2020) // 2020 sets the full year for a specified date according to universal time GMT
setUTCHours()
setUTCMilliseconds()
setUTCMinutes()
setUTCMonth()
setUTCSeconds()
toLocaleTimeString()
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
now.toLocaleDateString(undefined, options); //neděle 19. července 2020
// PDT Pacific Daylight Time (UTC -7)
// GMT ... SET GMT TIME +- ZONE ... new Date('December 31, 1974 23:59:30 GMT-3:00');
toGMTString() // DEPRECATED!!!! use toUTCString()
// Using UTC instead GMT!!!
var d = new Date("2020-07-15T00:00:00.000+07:00"); // UTC + 7
console.log(d.toISOString()); // "2020-07-14T17:00:00.000Z"
console.log(d.valueOf()); // 1594746000000
toISOString() // "2020-07-14T17:00:00.000Z"
toJSON() // "2020-07-14T17:00:00.000Z"
toSource() //This feature is obsolete!!!! Dont use!!!!
toString() // "Tue Jul 14 2020 19:00:00 GMT+0200 (Středoevropský letní čas)"
toUTCString() // "Tue, 14 Jul 2020 17:00:00 GMT"
valueOf() // 1594746000000
Udaje o prohlížeči
alert(navigator.appName); // Netscape
alert(navigator.appVersion); // 5.0(Windows; en-US)
alert(navigator.appCodeName); // Mozilla
alert(navigator.appMinorVersion); // subverze prohlížeče
alert(navigator.browserLanguage);
alert(navigator.cookieEnabled); // true - false
alert(navigator.cpuClass);
alert(navigator.onLine); // true když je připojen k síti
alert(navigator.platform);
alert(navigator.systemLanguage);
alert(navigator.userAgent);
alert(navigator.userLanguage);
// zjisteni detekce prohlizece Google Chrome
var bool_is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
Jak vytvořit slovník podstatných jmen.
Velmi snadno. Stačí si stáhnout slovník pro kontrolu pravopisudo Open Office org a tam již druhy slov májí za lomítkem určující znaky.
//wiki.services.openoffice.org/wiki/Dictionaries#Czech_.28Czech_Republic.29
Ukázka obsahu slovníku:
alokuce/Zalokující/YN
alokátor/H
alolex/H
alomorf/H
aloový/YKRN
aloparentální/YKR
alopatický/YCRN
alopatie/Z
Dodržujte licence slovníků
Editace: 18 10 2016
Počet článků v kategorii: 77
Url:php-get-variable-type-php