Asked  7 Months ago    Answers:  5   Viewed   37 times

How do I change the color of an echo message and center the message in the PHP I've written. The line I have is:

echo 'Request has been sent. Please wait for my reply!';

 Answers

86

How about writing out some HTML tags and some CSS if you're outputting this to the browser?

echo '<span style="color:#AFA;text-align:center;">Request has been sent. Please wait for my reply!</span>';

Won't work from console though, only through browser.

Wednesday, March 31, 2021
 
mcography
answered 7 Months ago
45

<? and <?= are called short open tags, and are not always enabled (see the short_open_tag directive) with PHP 5.3 or below (but since PHP 5.4.0, <?= is always available).

Actually, in the php.ini-production file provided with PHP 5.3.0, they are disabled by default:

$ grep 'short_open' php.ini-production
; short_open_tag
short_open_tag = Off

So, using them in an application you want to distribute might not be a good idea: your application will not work if they are not enabled.

<?php, on the other side, cannot be disabled -- so, it's safest to use this one, even if it is longer to write.


Except the fact that short open tags are not necessarily enabled, I don't think there is much of a difference.

Wednesday, March 31, 2021
 
Student
answered 7 Months ago
20

Form basics 101:

~~~index.php~~~
<form action='the_new_page.php' method='POST'>
  <input type='text' name='first_thing'>
  <input type='hidden' name='some_hidden_guy' value='1'>
  <input type='submit' name='submit_button' value='submit'>
</form>

When a user submits the above form, the browser will direct them to the_new_page.php, and the_new_page.php will know all of the form information.

Forms pass the name and the value, nothing else for as what you need to know. id is PURELY for html purposes, and as a rule in HTML, you are not allowed to have more than one element with the same ID. People usually confusingly name the id of the form field the same as the "name" of the form field, which makes learning what each means pretty difficult.

Thus, after submitting the form it will then go to your second page and then you can do:

~~~the_new_page.php~~~
//You can then do
echo $_POST['some_hidden_guy'] //will be 1
echo $_POST['first_thing'] //Will be whatever you inserted into the text box

If you want the form to go back to the current page you're on, you simply leave the action blank, either as <form action=''> or <form method='POST'>

Persisting the same information for multiple pages!

Now, this is a very not programmer way to do this, as you should find a way to not have to repeat the same code on ever page. If you do not, and I'm warning you now.. maintenance of this app will become a nightmare as you'll have to edit every single page every single time you want to add a new field. On to the example.

Now, say you passed information to car.php and you now want to use it on carplan.php.

~~~car.php~~~
    <form action='carplan.php' method='GET or POST, whichever it is you be using using'>
        <input type='hidden' name='Date' value='<?php echo $_GET['date'] ?>'>
        <input type='hidden' name='some_other_thing' value='<?php echo $_GET['some_other_thing'] ?>'>
        <option name='plan_id'>
            <?php foreach($plans as $plan): ?>
                <select value='<?php echo $plan['id'] ?>'><?php echo $plan['name'] ?>'>
            <?php endforeach; ?>
        </option>
        <input type='submit' name='submit' value='Get That Plan'>
    </form>

And finally on carplan.php

    ~~~carplan.php~~~
    <form action='the_next_step.php' method='GET or POST, whichever you be using'>
        <input type='hidden' name='Date' value='<?php echo $_GET['date'] ?>'>
        <input type='hidden' name='some_other_thing' value='<?php echo $_GET['some_other_thing'] ?>'>
        <input type='hidden' name='plan_id' value='<?php echo $_GET['plan_id']?>'>
        <input type='submit' name='submit' value='The next step!'>
    </form>
Wednesday, March 31, 2021
 
MGP
answered 7 Months ago
MGP
40

You may have an apostrophe in the copied text and it's being converted into a curled apostrophe (see: http://www.dwheeler.com/essays/quotes-in-html.html). If you're just echoing it back out to the screen, you could wrap the $_POST['content'] in a htmlentities().

Saturday, May 29, 2021
 
EastSw
answered 5 Months ago
88

Specify android:duplicateParentState='true' on your TextView.

Friday, August 13, 2021
 
c0m4
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :