Skip to content

Tag: php

How can “round” return a float?

PHP float type is IEEE-754 binary64. The number 59.95 cannot be stored precisely in binary. In IEEE-754 binary64 the representation of 59.95 should be 59.9500000000000028421709430404007434844970703125. However, when I do It returns 59.95. How is that possible? Also the function round claims to return the roun…

OpenApi for php doesn’t render enum values correctly

I am building some documentation using OpenApi and Swagger, but I am unable to test it because of a js error. I want to define a parameter that will accept specific values so I added enum in the schema attribute. I am defining the orderBy parameter in a GET request like this When the documentation is generate…

laravel feature tests with locales

I am new to Laravel and I am having an issue to write a test function that asserts that the HTTP response of my welcome page is 200 knowing that I have EN and FR locales defined, meaning that the test should test both localhost:8000/en and localhost:8000/fr. This is my exampletest.php: I don’t like writ…

PHP simpleXMLelment xpath returns unexpected results

I have executed the following code on the the sample XML at the bottom of the question and I am getting unexpected results. I would expect this to return only the two record nodes that are children of the current addresses node. But, it actually returns all 5 of the record nodes of the original $xml element. …

How to fix? PHP variable not shows values inside function

I want to pass the variable in a function but get an error : Working Example : Not Working : Answer What you are looking for is the “USE” keyword (for anonymous functions, as you are using in your second example). This allows additional variables from the parent scope to be passed into the closure…

Symfony Update data with a post request

I am currently trying to update a Person in a table. The Table looks the following: I want to be able to update the First-and Lastname and also the nin when I click on the Submit button. My twig file looks like this: And my controller is the following: Currently when I click update I just fill it what’s…