Skip to content

Tag: php

(PHP) Adding a ‘guess counter’ to a random number game

I need to modify a block of code and add a counter regarding how many times it took the user to guess the right number. I was wondering how it would be properly implemented into my code. This is what I have so far. Answer You have to use PHP Sessions to keep track of the count. All you have

Symfony2 generate controller inside custom folder

Symfony2 has a command for generating controllers http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_controller.html Command’s default behavior is to generate the given controller inside controller folder within the bundle. Is it possible to customize the folder where the con…

PHP AJAX echo json data before then sleep

I have tried out couple answers here but none worked. I have this basic honeypot script: I am trying to echo the json message and then sleep. But now it is first do sleep then echo the message. Any idea how to do it the good way? Answer Most likely the echo’d data is just being buffered rather than sent

php shorthand return statement

So i was just recently looking for some examples of validating a unix timestamp. One code chunk that kept reappearing was this: Now I have looked for shorthand return if statements which I think this might be but I am not having any luck. can anyone explain to me how this function is deciding what to return a…

Laravel: getting a single value from a MySQL query

I’m trying get a single value from MySQL database using laravel but the problem I’m getting an array . this is my query result in MySQL command line: my laravel function: expected $data value is a string with value= Admin but what i get is : [{“groupName”:”Admin”}] Answer E…