Saturday, 28 September 2013

In PHP would this be deemed correct?

In PHP would this be deemed correct?

I already wrote a post about an issue I had before about this but I had
that issue taken care of. Like my last post I have a form, text-box and a
button. I have everything done with this including Printing the original
word, Printing the number of characters in the word, Printing the word in
all caps and Printing the word in reverse order. My only issue I'm having
is trying to get whatever text I enter and then click the button to output
to Print the first letter of the word and Print the last letter of the
word. I've been doing a lot of looking around of PHP.net and I found that
substr is used to return a part of a string that I could use. The only
issue is when I write the code for it and try to execute my program it
errors out on that specific line. I'm not looking for the answer but could
someone just take a look and see what I'm doing wrong because I understand
everything completely but this is the only thing I'm hung up on.
$first = substr($_POST['entertext']);
echo "The first letter of the word is " . $first. "<br />\n";
$last = substr($_POST['entertext']);
echo "The first letter of the word is " . $last. "<br />\n";

No comments:

Post a Comment