简体   繁体   中英

What is settimeout proper syntax?

Hi I'm trying to use settimeout but gets an erro "Call to undefined function setTimeout() in". I based my code on w3schools. Here's my code:

<?php

function compareperc(){
    echo "hello";
}

setTimeout(compareperc(), 1000);

?>

To delay execution in PHP, you can use the following code:

<?php

function compareperc(){
    echo "hello";
}

sleep(1);
compareperc();

?>

I wouldn't necessarily say it's advisable, but this would be the equivalent without trying to use JavaScript where it won't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM