Z
Z
zeaovede2022-03-28 14:42:47
PHP
zeaovede, 2022-03-28 14:42:47

How to write classes in php code?

I tried to display my divs via php, and everything would be fine, but only the first class in the div is taken into account. Those. if it looks like this:

if (isset($_POST['currentTier']) && strpos($_GET['type'], 'placements')===false) $description .= "<div id=details-2 class=col-12 col-xl-4 col-lg-12 mb-xl-5 mb-5><div class=d-flex b-skills><div class=height:70px;><div class=text-bold>Текущая лига:</div> <div class=text-primary> ".$tiers[$_POST['currentTier']]."</div></div></div></div></br>";

Then the first class will work at the output, and all classes that are registered after col-12 will not work.
In code it looks like this
62419e29df2b8059401611.png
Is there a way to make the other classes work?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2022-03-28
@FanatPHP

We explain with a simple example how logical thinking can be used in programming.

$description = "<div id='details-2' class='col-12 col-xl-4 col-lg-12 mb-xl-5 mb-5'><div class='d-flex b-skills'><div class='height:70px;'><div class='text-bold'>";
echo $description,"\n";
echo addslashes($description);

We take our long-suffering word description and display it as it is. And - about a miracle! - all quotes are in place.
After that, we add the function of adding backslashes. And we see that they are added to the quotes .
From which we can make a logical conclusion that between the creation of the long-suffering description variable and the output of its contents to the screen, there is some shit code that, for some unknown reason, adds backslashes to it.
And discover for yourself the magic keys Ctrl-U
If you have problems with generating html, you need to look exactly what your code has generated , and not those beautiful things that the inspector diligently paints on it.

B
black1277, 2022-03-28
@black1277

Quote all classes to single or double (need to be escaped)

if (isset($_POST['currentTier']) && strpos($_GET['type'], 'placements')===false) $description .= "<div id=details-2 class='col-12 col-xl-4 col-lg-12 mb-xl-5 mb-5'><div class='d-flex b-skills'><div class='height:70px;'><div class='text-bold'>Текущая лига:</div> <div class='text-primary'> ".$tiers[$_POST['currentTier']]."</div></div></div></div></br>";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question