GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech If statement problem :( (https://gfy.com/showthread.php?t=1355544)

Publisher Bucks 06-14-2022 01:26 PM

If statement problem :(
 
Quote:

<?php if($website) { ?><a href="http://<?php echo $website; ?>" target="<?php echo $name; ?>"><?php echo $name; ?></a><?php } ?>
Any idea why this is removing the $name field completely in addition to the link?

All Im trying to get it to do is still display the name, just remove the href link if no website is included in the DB :Oh crap

redwhiteandblue 06-14-2022 01:34 PM

Because if the condition in the if statement is false, none of the code inside the curly braces will execute.

Publisher Bucks 06-14-2022 01:35 PM

Quote:

Originally Posted by redwhiteandblue (Post 23011613)
Because if the condition in the if statement is false, none of the code inside the curly braces will execute.

Gotcha, thank you!

redwhiteandblue 06-14-2022 01:37 PM

BTW, rather than writing
Code:

<?php echo $website; ?>
you can shorten this to
Code:

<?=$website;?>

Publisher Bucks 06-14-2022 01:43 PM

Quote:

Originally Posted by redwhiteandblue (Post 23011616)
BTW, rather than writing
Code:

<?php echo $website; ?>
you can shorten this to
Code:

<?=$website;?>

Good to know!

I was actually going to post in a few weeks to see where I could shorten some of the code I'm using on my admin system and I'm sure its over-inflated, but I need to get things finished up with it first.

sarettah 06-14-2022 02:20 PM

Be careful using short codes. They require an ini setting that is not always turned on. So code that works on one server may not work on another.

It can also lead to some issues when dealing with xml which also uses an <? ?> Syntax.

.

redwhiteandblue 06-14-2022 03:47 PM

Quote:

Originally Posted by sarettah (Post 23011631)
Be careful using short codes. They require an ini setting that is not always turned on. So code that works on one server may not work on another.

It can also lead to some issues when dealing with xml which also uses an <? ?> Syntax.

.

You're talking about short open tags - <? ... ?> which are possibly being deprecated.

The short echo tags <?= ... ?> are not dependent on an ini setting https://www.php.net/manual/en/langua...ax.phptags.php and there's no proposal to deprecate them.
They are actually line 1 of the PSR-1 coding standard https://www.php-fig.org/psr/psr-1/

Not that anyone actually follows that...

sarettah 06-14-2022 04:04 PM

Quote:

Originally Posted by redwhiteandblue (Post 23011653)
You're talking about short open tags - <? ... ?> which are possibly being deprecated.

The short echo tags <?= ... ?> are not dependent on an ini setting https://www.php.net/manual/en/langua...ax.phptags.php and there's no proposal to deprecate them.
They are actually line 1 of the PSR-1 coding standard https://www.php-fig.org/psr/psr-1/

Not that anyone actually follows that...




Interdasting. I learn something new about every 2 minutes.

Thanks for that.

.


All times are GMT -7. The time now is 04:45 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc