0

I'm trying to style a header with content from PHP but I can't seem to get it working.

What styling I'm trying to apply:

.PageCounter h3{
color: white;
text-align: left;
padding-left: 26%;
font-weight: bold;
display: block;
margin-bottom: 50px;
}

What works to style:

<div class="PageCounter">
<h3>You are visitor number: 32423</h3>
</div>

What doesn't work:

<?php
$number = trim(file_get_contents('hits.txt'));
echo "<div class=\"PageCounter\"><h3>You are visit number: " , $number + 1 , "</h3></div>";
?>

How would I get this working?

EDIT: AFAIK the string is in correct syntax as using . to combine the strings instead of , results in the echo not showing at all. (and stop closing my question saying it's been answered by linking something irrelevant)

I tap HS
  • 1
  • 1

1 Answers1

0

Be sure on your PHP you have included the css. On your PHP code you have a wrong syntax. Put this:

echo '<div class="PageCounter"><h3>You are visit number: ' . $number + 1 . '</h3></div>';

I'd changed commas by dots. I hope it will work.

Adrian Cobo
  • 163
  • 1
  • 10
  • And to make it more readable I would change some of the `"` to `'` – RiggsFolly Aug 18 '20 at 16:46
  • When using dots instead of commas to combine the strings it won't even display. Surely this can't be right. – I tap HS Aug 18 '20 at 16:54
  • Which is not displaying? Please explain what is not working: the display on PHP, the style with CSS, ... – Adrian Cobo Aug 19 '20 at 18:22
  • When using dots to combine the strings, the echo doesn't display on the page at all. Using commas does the job. Neither outputs gets styled by the css. – I tap HS Aug 20 '20 at 00:10
  • ¿Are you adding the css on the page with ? https://www.w3schools.com/css/css_howto.asp But as FluffyKitten said, to concat PHP strings you must use dots. Something is wrong with your PHP, is very odd working this way. All the PHP manuals said. Can you share a Gist or somewhere your code is online? – Adrian Cobo Aug 20 '20 at 09:25