Hi guys so I have post and comment system, So I want to show comment section if the day of the post +7 days. if they see the post on day 8 of the post created they can’t comment. Here is my code that I try but I still dont get it : I know it’s totally a dumb code,
Tag: if-statement
PHP check if time falls within range, questioning common solution
I have to check if the current daytime falls in a specific range. I looked up the internet and found several similar solutions like this one: If both conditions have to be true, how can this bis achieved when we assume that $start is 06:00:00 and $end is 02:00:00. If we make the assumption that it is 01:00:00…
WordPress IF ELSEIF and ELSE Statement
Can someone explain why this does not work? Basically if not the home page or a page with ID 105 show the contact form, else if it is the home page show ‘no side bar’ else for everything else show ‘different side bar’ – it doesnt work as the home page still shows the ‘diffe…
one line if statement in php
I’d like to to some thing similar to javascripts var foo = true; foo && doSometing(); but this doesnt seem to work in php. I’m trying to add a class to a label if a condition is met …
PHP if shorthand and echo in one line – possible?
What’s the best, preferred way of writing if shorthand one-liner such as: Plot twist: I need to echo $foo or echo $bar. Any crazy tricks? 🙂 Answer edit: here’s a good read for you on the topic edit: more to read
Refer to specific product ID in WordPress / WooCommerce in PHP
I have this script that adds a download button to every product page in WooCommerce but I need to exclude a product page from having the download button. I tried changing the first line to but it is failing, I think I am on the right track but need to reference it correctly (It should only enter the if functi…
Why does ‘Cannot break/continue 1 level’ comes in PHP?
I am getting sometimes this error on production at: I have tried to reproduce this issue. But not getting any progress. $Id, $Properties having value received. Does anyone know when does ‘Cannot break/continue 1 level’ comes in PHP? I have seen this post PHP Fatal error: Cannot break/continue. But…
Is there any way in php to make SWITCH opreator compare cases strict?
I have such control structure: And my NULL case is never invoked because as I found in php manual: Note that switch/case does loose comparision. I know I can use IF instead of SWITCH but I wouldn’t like to, I have already some IF’s in every CASE of my SWITCH. Is there any way to rewrite somehow SW…
How to reduce the number of if-else statements in PHP?
I found that there are many if-else statements, especially nested if else statements, these statements make my code less readable. How to reduce the number of if else statements in PHP? My tips are as follows: 1.Use a switch statement when it is suitable; 2.use exit() statement when it is feasible; 3. Use ter…