-1

I am working on a website in which I want to do inline styling inside php tags.

<?php 
   if($data['item']->hello_world!=null)
   {
   echo "policy:";

   echo strtolower($data['item']->hello_world->name);
   echo "<br>";
   echo strtolower($data['item']->hello_world->description); 
   }
   ?><?php 
   if($data['item']->hello_world!=null)
   {
   echo "policy:";
   echo strtolower($data['item']->hello_world->name);
   echo "<br>";
   echo "<br>";
   echo strtolower($data['item']->hello_world->description); 
   }
 ?>

The data which I want to style coming from the php code is:

echo strtolower($data['item']->hello_world->name);


Problem Statement:

I am wondering what changes I should make in the php code so that I am able to do styling for the above mentioned line.

flash
  • 1,455
  • 11
  • 61
  • 132
  • to do inline styling you have to put your output in something like a `
    ` or a `

    `. You need to define that and put `style=''` in there

    – Forbs Aug 13 '18 at 22:45
  • 1
    Have you tried anything? What styling do you want? E.g. `echo "

    " . strtolower($data['item']->hello_world->name) . "

    ";`
    – James Aug 13 '18 at 22:45

1 Answers1

1

To inline style the element:

echo '<span style="color: red">' . strtolower($data['item']->hello_world->name) . '</span>';
Nick
  • 138,499
  • 22
  • 57
  • 95
  • 1
    The question is entirely about "inline" styling. Which IMO doesn't warrant answering anyway as this is a tutorial request and not (eg) help request with their inline style not working. – James Aug 13 '18 at 22:47
  • @James I missed the "inline" at the top of the question so that is a fair point and I will edit appropriately. However I disagree with you about not warranting an answer. Questions which are answered in the comments remain open forever and result in people wasting time looking at them to see if they should answer. So either the question should be answered, or it should be closed and deleted, but I don't see any good reason for the latter. – Nick Aug 13 '18 at 22:51
  • "*Questions which are answered in the comments remain open forever*" no they get closed and deleted. It's ones with answers that are harder to delete. This question is a request for a tutorial "How do I do inline styles" and not an answerable programming questions like "I have this style but it's not working". The fact you answered with `span` without knowing what style they want proves this. What if they want `

    ` or `

    ` or something else?
    – James Aug 13 '18 at 22:55
  • @James OP only wants to inline style a piece of data. A `span` is almost certainly the only appropriate element to use. And if it's not, OP can always change it themselves. – Nick Aug 13 '18 at 22:59
  • "*A span is almost certainly the only appropriate element to use*" span isn't the only appropriate inline style element. All we're doing here is showing an example of *what inline style is*, and nothing towards what the OP might want. "*And if it's not, OP can always change it themselves.*" this is a bit contradictory - you say they can do it themselves, but answer their question telling them how to do it? Either they know how to inline style or they don't and thus we need to know what exactly they want to be able to help them. We obviously disagree so let's leave it there :) – James Aug 13 '18 at 23:07