Skip to main content

I need help getting rid of a fatal error in php [closed]

Hi I'm writing code for a programme that plays blackjack and I keep getting a redeclaration error on a function I'm writing and would like some help

 function displayCard($card)
     {
        $picNum = ( ($card % 5) + 1);
        echo "<img src='images/" . $picNum  . ".png' width='50' height='60' >";

        
         if ($picNum == 1)
             echo "<img src='images/1.png'>";
         elseif ($picNum == 2)
             echo "<img src='images/2.png'>";
         elseif ($picNum == 3)
             echo "<img src='images/3.png'>";    
         elseif ($picNum == 4)
             echo "<img src='images/4.png'>";
         elseif ($picNum == 5)
             echo "<img src='images/5.png'>"; 
             elseif ($picNum == 6)
             echo "<img src='images/6.png'>";
         elseif ($picNum == 7)
             echo "<img src='images/7.png'>";    
         elseif ($picNum ==8)
             echo "<img src='images/8.png'>";
         elseif ($picNum == 9)
             echo "<img src='images/9.png'>"; 
             elseif ($picNum == 10)
             echo "<img src='images/10.png'>";
         elseif ($picNum == 11)
             echo "<img src='images/11.png'>";    
         elseif ($picNum == 12)
             echo "<img src='images/12.png'>";
         elseif ($picNum == 13)
             echo "<img src='images/13.png'>"; 
             elseif ($picNum == 14)
             echo "<img src='images/14.png'>";
         elseif ($picNum == 15)
             echo "<img src='images/15.png'>";    
         elseif ($picNum ==16)
             echo "<img src='images/16.png'>";
         elseif ($picNum == 17)
             echo "<img src='images/17.png'>";
             elseif ($picNum == 18)
             echo "<img src='images/18.png'>";
         elseif ($picNum == 19)
             echo "<img src='images/19.png'>";    
         elseif ($picNum == 20)
             echo "<img src='images/20.png'>";
         elseif ($picNum == 21)
             echo "<img src='images/21.png'>"; 
             elseif ($picNum == 22)
             echo "<img src='images/22.png'>";
         elseif ($picNum == 23)
             echo "<img src='images/23.png'>";    
         elseif ($picNum ==24)
             echo "<img src='images/24.png'>";
         elseif ($picNum == 25)
             echo "<img src='images/25.png'>"; 
             elseif ($picNum == 26)
             echo "<img src='images/26.png'>";
         elseif ($picNum == 27)
             echo "<img src='images/27.png'>";    
         elseif ($picNum == 28)
             echo "<img src='images/28.png'>";
         elseif ($picNum == 29)
             echo "<img src='images/29.png'>"; 
             elseif ($picNum == 30)
             echo "<img src='images/30.png'>";
         elseif ($picNum == 31)
             echo "<img src='images/31.png'>";    
         elseif ($picNum ==32)
             echo "<img src='images/32.png'>";
         elseif ($picNum == 33)
             echo "<img src='images/33.png'>";
             elseif ($picNum == 34)
             echo "<img src='images/34.png'>";
         elseif ($picNum == 35)
             echo "<img src='images/35.png'>";    
         elseif ($picNum ==36)
             echo "<img src='images/36.png'>";
         elseif ($picNum ==37)
             echo "<img src='images/37.png'>"; 
             elseif ($picNum ==38)
             echo "<img src='images/38.png'>";
         elseif ($picNum ==39)
             echo "<img src='images/39.png'>";    
         elseif ($picNum =40)
             echo "<img src='images/40.png'>";
         elseif ($picNum ==41)
             echo "<img src='images/41.png'>"; 
             elseif ($picNum == 42)
             echo "<img src='images/42.png'>";
         elseif ($picNum == 43)
             echo "<img src='images/43.png'>";    
         elseif ($picNum == 44)
             echo "<img src='images/44.png'>";
         elseif ($picNum == 45)
             echo "<img src='images/45.png'>"; 
             elseif ($picNum == 46)
             echo "<img src='images/46.png'>";
         elseif ($picNum == 47)
             echo "<img src='images/47.png'>";    
         elseif ($picNum ==48)
             echo "<img src='images/48.png'>";
         elseif ($picNum == 49)
             echo "<img src='images/49.png'>";
         elseif ($picNum == 50)
             echo "<img src='images/50.png'>";    
         elseif ($picNum ==51)
             echo "<img src='images/51.png'>";
         elseif ($picNum == 52)
             echo "<img src='images/52.png'>";
    }
    
}

Fatal error: Cannot redeclare displayCard() (previously declared in C:\xampp\htdocs\assignment\blackjack.php:82) in C:\xampp\htdocs\assignment\blackjack.php on line 82

*

This is the error I keep getting on this part, I'm unsure what the issue might be with it. it is being both declared and redeclared on the same line of code, though I have only entered DisplayCard once I have an earlier function called displayCards which is operating perfectly. I tried changing the displayCard name to displayCardio, but had the same issue.



source https://stackoverflow.com/questions/68953902/i-need-help-getting-rid-of-a-fatal-error-in-php

Comments

Popular posts from this blog

Where and how is this Laravel kernel constructor called? [closed]

Where and how is this Laravel kernel constructor called? public fucntion __construct(Application $app, $Router $roouter) { } I have read the documentation and some online tutorial but I can find any clear explanation. I am learning Laravel and I am wondering where does this kernel constructor receives its arguments from. "POSTMOTERM" CLARIFICATION: Here is more clarity.I have checked the boostrap/app.php and it is only used for boostrapping the interfaces into the container class. What is not clear to me is where and how the Kernel class is instatiated and the arguments passed to the object calling the constructor.Something similar to; obj = new kernel(arg1,arg2) or, is the framework using some magic functions somewhere? Special gratitude to those who burn their eyeballs and brain cells on this trivia before it goes into a full blown menopause alias "MARKED AS DUPLICATE". To some of the itchy-finger keyboard warriors, a.k.a The mods,because I believe in th...

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

Confusion between commands.Bot and discord.Client | Which one should I use?

Whenever you look at YouTube tutorials or code from this website there is a real variation. Some developers use client = discord.Client(intents=intents) while the others use bot = commands.Bot(command_prefix="something", intents=intents) . Now I know slightly about the difference but I get errors from different places from my code when I use either of them and its confusing. Especially since there has a few changes over the years in discord.py it is hard to find the real difference. I tried sticking to discord.Client then I found that there are more features in commands.Bot . Then I found errors when using commands.Bot . An example of this is: When I try to use commands.Bot client = commands.Bot(command_prefix=">",intents=intents) async def load(): for filename in os.listdir("./Cogs"): if filename.endswith(".py"): client.load_extension(f"Cogs.{filename[:-3]}") The above doesnt giveany response from my Cogs ...