Click here to Skip to main content
16,002,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
CODE:

 <?php
        function detect()
        {
         $arr_browsers = ["Opera", "Edg", "Chrome", "Safari", "Firefox", "MSIE", "Trident"];
 
         /* @var $_SERVER type */
         $agent = $_SERVER['HTTP_USER_AGENT'];
         foreach ($arr_browsers as $browser) {
         if (\strpos($agent, $browser) === true){
           echo 'Dátum zákroku / Date of procedure [YYYY-MM-DD]';
           echo '<p><input class="w3-input w3-border" required name="datum_zakroku"></p>';}
         else if (\strpos($agent, $browser) === true){
           echo 'Dátum zákroku / Date of procedure [YYYY-MM-DD]';
           echo '<p><input class="w3-input w3-border" required name="datum_zakroku"></p>';}        
         else{
            '<div class="w3-text-d1"><p>Dátum zákroku / Date of procedure</p></div>
            <p><input class="w3-input w3-border" type="date" required name="datum_zakroku"></p>';}}
        detect()
      ?>


What I have tried:

I checked all brackets to fix my problem, but i think i missed somethinng. Anyway there is still Syntax error about expected end of file. Please can you help?
Posted
Updated 15-Mar-21 2:53am
v4

1 solution

Fairly easy to see the problem if you format your code properly with the correct indentation:
PHP
<?php
function detect()
{
    $arr_browsers = ["Opera", "Edg", "Chrome", "Safari", "Firefox", "MSIE", "Trident"];
     
    /* @var $_SERVER type */
    $agent = $_SERVER['HTTP_USER_AGENT'];
    foreach ($arr_browsers as $browser) {
        if (\strpos($agent, $browser) === true){
            echo 'Dátum zákroku / Date of procedure [YYYY-MM-DD]';
            echo '<p><input class="w3-input w3-border" required name="datum_zakroku"></p>';
        }
        else if (\strpos($agent, $browser) === true){
            echo 'Dátum zákroku / Date of procedure [YYYY-MM-DD]';
            echo '<p><input class="w3-input w3-border" required name="datum_zakroku"></p>';
        }
        else{
            '<div class="w3-text-d1"><p>Dátum zákroku / Date of procedure</p></div>
            <p><input class="w3-input w3-border" type="date" required name="datum_zakroku"></p>';
        }
    }
// see what is missing at this point
    detect()
?>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900