<style>
.yellow {
color: Yellow
}
</style>
<script>
document.addEventListener('DOMContentLoaded', () => {
let easyTimer = (function (words, timer, greetings, element) {
let render = val => element.innerText = val ? val : timer === 0 ? words[parseInt(Math.random() * words.length)] : timer;
render(`Готов к лету?`);
setTimeout(() => {
setTimeout(() => element.classList.remove('yellow'), 1000);
let interval = setInterval(
() => timer - render() && 0 === timer && clearInterval(interval), 1000
)
}, greetings * 1000)
})(
['Да', 'Конечно да'],
5,
1, // сколько секунд показывать "Ответ готов"
document.querySelector('.rnd-word.yellow')
)
})
</script>
<div>
<div class="rnd-word yellow"></div>
</div>
<style>
.red {
color: Blue
}
</style>
<script>
document.addEventListener('DOMContentLoaded', () => {
let easyTimer = (function (words, timer, greetings, element) {
let render = val => element.innerText = val ? val : timer === 0 ? words[parseInt(Math.random() * words.length)] : timer;
render(`Хотел бы на море?`);
setTimeout(() => {
setTimeout(() => element.classList.remove('red'), 1000);
let interval = setInterval(
() => timer - render() && 0 === timer && clearInterval(interval), 1000
)
}, greetings * 1000)
})(
['Да', 'Нет'],
5,
1, // сколько секунд показывать "Ответ готов"
document.querySelector('.rnd-word.red')
)
})
</script>
<div>
<div class="rnd-word red"></div>
</div>
$start = microtime();
function myIsInt($var) {
if ((int)$var == $var) {
return true;
} else {
return false;
}
}
for ($i = 0; $i <= 100000; $i++)
$myvar = myIsInt("5qwerty");
echo microtime() - $start;
$start = microtime();
for ($i = 0; $i <= 100000; $i++)
$myvar = preg_match('/^\d+$/', '5qwerty');
echo microtime() - $start;