-2

I have this code:

enter image description here

As you can see I have put the PHP code on the second line, since I don't want to exceed the red line (80 characters).

The problem: the URL is generated like this:

enter image description here

As you can see there is an extra space between the = and value1. How to avoid that space?

tirenweb
  • 30,963
  • 73
  • 183
  • 303
  • 2
    Put it all on one line. `">` – blackandorangecat May 25 '17 at 22:18
  • Did you use tabs or spaces to indent it? – j08691 May 25 '17 at 22:18
  • @blackandorangecat but I don't want to exceed the red line.. – tirenweb May 25 '17 at 22:22
  • @j08691 I have tried tabs and spaces and the result is the same. – tirenweb May 25 '17 at 22:22
  • @ziiweb Well, in order to remove that space you need to put it all on the same line... – blackandorangecat May 25 '17 at 22:23
  • yeah put it on one line, the spaces you are seeing are from it being on two lines. go past the red bar, its the only way :) – ATechGuy May 25 '17 at 22:23
  • 2
    You need to put at least the ` – CBroe May 25 '17 at 22:24
  • because scrolling is bad? your coding on a tiny screen? any case, you cant have it both ways –  May 25 '17 at 22:24
  • You can't do that what you exactly want. In HTML, whitespaces are't ignored, and if you put the PHP code in a new line, there will be some whitespaces. See also: https://stackoverflow.com/questions/2628050/ignore-whitespace-in-html – klenium May 25 '17 at 22:27
  • An 80 character per line arbitrary limit seems pretty weird. Why are you limiting yourself to this? Furthermore I count 55 characters for you whole opening `a` tag. An actual option to get around this is to put the whole `href` attribute its own line. If you're constrained by your arbitrary character count I'd put each attribute on its own line – Jon P May 25 '17 at 22:31

1 Answers1

1

Never a good practice to split a string. If you don't want to exceed the limit, probably best thing to do is to move the whole string to the next line.

<a href=
  "my_file.php?parameter1=<?php echo 'value1';?>">

You could also try using the php short tags <??> instead of the whole <?php ?>.

Another option would be to output the whole line with php like this (with the string concat .):

<?php echo "<a href='my_file.php?parameter1=".
   'value1'."'>"; ?>
Felix Guo
  • 2,700
  • 14
  • 20