Clear cache in Symfony: `cache:clear` or `rm -rf`?

cache:clear wipes previously created cache items, but also, it does a cache warm-up. Upon this, you application should load very fast due to the fact that cache was already pre-populated. On the other hand, rm -rf does only one part of the job. You should notice performance impact when you try to load you app the first time after … Read more

PHP date yesterday [duplicate]

date() itself is only for formatting, but it accepts a second parameter. To keep it simple I just subtract 24 hours from the unix timestamp. A modern oop-approach is using DateTime Or in your case (more readable/obvious) (Because DateInterval is negative here, we must add() it here) See also: DateTime::sub() and DateInterval

What is a templating language?

The premise behind a template language is that the language is “embedded” within some other master document. Specifically, on your average document, the total size of the document is mostly document source than template language. Consider two contrived examples: vs You can see in the first example, the language wraps the document text. In the … Read more

Session variables not working php

Make sure session_start(); is called before any sessions are being called. So a safe bet would be to put it at the beginning of your page, immediately after the opening <?php tag before anything else. Also ensure there are no whitespaces/tabs before the opening <?php tag. After the header redirect, end the current script using exit(); (Others have also suggested session_write_close(); and session_regenerate_id(true), you can try those as … Read more

Php create a file if not exists

Try using: for testing if you can create a file there or not. If you can’t create the file, that’s probably because the directory is not writeable by the web server user (usually “www” or similar). Do a chmod 777 folder to the folder you want to create the file and try again. Does it work?

CSS background images in WordPress

PHP code cannot run in .css file, however you can use inline style, such as: or The above would be useful when working with custom fields for dynamic image paths. If the image is located in the theme directory, PHP won’t be needed, let’s say the image folder is directly under the theme folder /theme-name/images, and the stylesheet … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)