Hi guys! I need to show a $qs within an echo, but I have no clue how. Right now I have this and it's not showing: echo '<a href="/?<?php echo $qs; ?>do=reportabuse&confirm=1">confirm</a>'; How do I make <?php echo $qs; ?> to actually show in this instance? Thanks!
As nico_swd's code shows, you are already IN PHP if you are using echo, so you don't need to open and close PHP again, you need to close the current string, add your variable, and open the string up again for the rest. Though I would suggest using commas (delimiters) instead of periods (string additions) -- it's a hair faster, uses less memory, but more importantly it executes in the order you THINK it's going to... Mind you, comma's only work when echoing and there are cases where string addition is preferred... but think about this example: <?php function echotest() { echo 'is '; } echo 'This ',echotest(),'a test<br />'; echo 'This '.echotest().'a test<br />'; ?> Code (markup): It will output: This is a test is This a test Code (markup): Why does that code do that? The string addition runs the function BEFORE the resulting string is sent to echo, while using comma's each 'piece' is sent one after the other. It's a distinction a lot of people starting out with PHP (and even many people who've done it for years) can get confused by. As such, I'd have it worded thus: echo '<a href="/?',$qs,'do=reportabuse&confirm=1">confirm</a>'; Code (markup): But really, either way will work since $qs is a variable. Generally speaking the whole <?php ?> two or three times a line crap most people vomit up just seems like sloppy coding to me (another strike against poorly coded crap like turdpress)... as a rule of thumb I prefer in most all the code I write to only <?php once at the start of my PHP file, and ?> once at the end, and that's IT. REALLY if I had my way, <?php ?> would be removed from the PHP specification as unnecessary and running contrary to the methodology of sane/secure code.
great, now you can mass report people to harrrass their accounts and services in bulk by adding them to a text list and pressing one submit button.
Nice, if you get it working you should send it to craigslist. They need a new system instead of all their troll'ers they have that stalk the site and try to slander,undermine and delete/ban posts for their bottom-level entertainment.