Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I style a PHP echo text? [closed]

Tags:

css

php

styling

I have the following code;

<?php
    function countryCityFromIP($ipAddr)
    {
        $url = "http://api.ipinfodb.com/v3/ip-city/?key=5cfaab6c5af420b7b0f88d289571b990763e37b66761b2f053246f9db07ca913&ip=$ipAddr&format=json";
        $d = file_get_contents($url);
        return json_decode($d , true);
    }

    if (isset($_REQUEST['submit']))
    {
       $ip = countryCityFromIP($_REQUEST['ip']);

       //print_r($ip);
       echo $ip['cityName'];
       echo $ip['countryName'];
    }
?>

<form method="post">
    <input type="text" name="ip" />
    <input type="submit" name="submit" value="Find" />
</form>

I need to style "echo $ip['cityName']" here. I tried a lot methods, but I am only getting an error.

like image 419
thomas Avatar asked Aug 15 '13 12:08

thomas


2 Answers

You can style it by the following way:

echo "<p style='color:red;'>" . $ip['cityName'] . "</p>";
echo "<p style='color:red;'>" . $ip['countryName'] . "</p>";
like image 144
Jothi Kannan Avatar answered Sep 19 '22 16:09

Jothi Kannan


Echo inside an HTML element with class and style the element:

echo "<span class='name'>" . $ip['cityName'] . "</span>";
like image 21
Naji Shmly Avatar answered Sep 17 '22 16:09

Naji Shmly