Jump to content

Script stopping before it should

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
dcord

dcord

    Newbie

  • Members
  • PipPip
  • 25 posts
hi all and Happy Thanksgiving to everyone

Can anyone tell me why this script stops at:
echo "<p>" . lcfirst($UppercaseText) . "</p>\n";

<?php
$StartingText = "mAdAm, i'M aDaM.";
$UppercaseText = strtoupper($StartingText);
$LowercaseText = strtolower($StartingText);
echo "<p>$UppercaseText</p>\n";
echo "<p>$LowercaseText</p>\n";
echo "<p>" . ucfirst($LowercaseText) . "</p>\n";
echo "<p>" . lcfirst($UppercaseText) . "</p>\n";
$WorkingText = ucwords($LowercaseText);
echo "<p>$WorkingText</p>\n";
echo "<p>" . md5($WorkingText) . "</p>\n";
echo "<p>" . substr($WorkingText,0.6) . "</p>\n";
echo "<p>" . substr($WorkingText,7) . "</p>\n";
echo "<p>" . strrev($WorkingText) . "</p>\n";
echo "<p>" . str_shuffle($WorkingText3) . "</p>\n"
?>

Thanks in advance

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Hello dcord, it stops actually at this line:
echo "<p>" . str_shuffle($WorkingText3) . "</p>\n"

You reference to the variable $WorkingText3 but that does not exist.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
dcord

dcord

    Newbie

  • Members
  • PipPip
  • 25 posts
before I added the lines:
echo "<p>" . md5($WorkingText) . "</p>\n";
echo "<p>" . substr($WorkingText,0.6) . "</p>\n";
echo "<p>" . substr($WorkingText,7) . "</p>\n";
echo "<p>" . strrev($WorkingText) . "</p>\n";
echo "<p>" . str_shuffle($WorkingText3) . "</p>\n"
it would only take me to the 3rd echo statment
after adding the above lines it only echoed back to the third echo statement.
are you saying you ran the script and got a different result? or can you tell by looking at it?
this code was copied directly from a text book trying to teach us how to Modify the case of a string.
I'ts hard to believe that a text book would have the code incorrect. but it wouldnt surprise me.
The $WorkingText is declared and referenced with the echo statement below it. or am I wrong about that?

thanks for your time

#4
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
dcord, I have just tested your code on my server and it works correctly. Check your server properties.

#5
dcord

dcord

    Newbie

  • Members
  • PipPip
  • 25 posts
here is what I get from my script. I upload it to my server and view it in a IE web brow

MADAM, I'M ADAM.
madam, i'm adam.
Madam, i'm adam.

then it stops

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Ah, it turns out lcfirst only exists in PHP 5.3.0+, you are likely using an older version and it is not available to you.

You can turn error reporting on and it should tell you that the function does not exist, try this at the beginning of your script:
error_reporting(E_ALL);
ini_set('display_errors', 1);
You can better see why yourself with that.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
dcord

dcord

    Newbie

  • Members
  • PipPip
  • 25 posts
Sorry I am not getting any error returns everything stays the same.

here is a stupid question for you.
How do I check which version I am running?
and what should my server settings be?

I am just using notepad++ to write my code, uploading ftp to my college and then viewing in a web browser

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
You can find out like this:
echo 'Current PHP version: ' . phpversion();

It is best to know a little more about your system to debug these problems.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.