Skip to content

Tag: php

How to catch a fatal error both in PHP 7 and 8?

I have a PHP 7 script, that basically does this: To be clear: if the class I am looking for is “Main” and can’t be found, I must display the text, else it’s supposed to throw the exception anyway. It works well with PHP 7, but PHP 8 does not catch the error. Instead, it shows: How am I…

After changing name of a file it goes parent directory

I’m writing a PHP code that takes names from input.txt file and with those names it changes the names of files in the image folder. My code is: It works but at last, files in the ‘image’ folder go C:wamp64wwwReplace image names with input directory. (Parent directory) Any idea why this happe…

Why cookies are added rather than changed?

I am developing a site where each user should have their own id. When I went into the console, I saw that the id was duplicated instead of being one. Is this normal and should it be? Answer Cookies, by default, use the path of the page that they are set for. You should explicitly set the path to /

Restore content file_get_content() function

I gave an image as a parameter to the file_get_content() function and received it as the output of a string. Now I want to do the opposite of this operation. What should I do? Answer You can write it back to an image file using file_put_contents Example: If you then look into your folder “images/”…

How to pass data to symfony form class without using static

I’ve got form class and i have to pass args to it but i can’t do that because i am using createNamed function which requires me to use namespace string. code: I can’t pass this data into entity, because it is an arguments for creating the form fields rather than data model. Answer Have you t…