Skip to content
View in the app

A better way to browse. Learn more.

The Armory

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Help Plz!

Featured Replies

Howdy

 

Ok, im needing some help.

 

Does this code make anysense to anyone that knows Php?

 

<html>

<head><title>Ex 1</title></head>

 

<?

$retAge="70";

echo "The Retirement Age is $retAge";

$myAge="30";

echo "You are $myAge years old";

yearsLeft="$retAge-$myAge";

?>

 

<?

echo "$retAge - $myAge=".($retAge-$myAge)."<br>

echo "You Have $yearsLeft Years Left!";

</html>

 

Ok, the idea is for a program to display how many years a user has left to retirement, (70 and 30 are pre defined) but i have no idea how to calculate vairables.

 

Any help would be much appreciated!

Here ya go Wellsy... btw, I always use parenthesis on my echo statements, makes them a little easier to read.

 

<html>

<head><title>Ex 1</title></head>

 

<?

$retAge=70;

echo ("The Retirement Age is $retAge.<br>");

$myAge=30;

echo ("You are $myAge years old.<br><br>");

$yearsLeft=$retAge-$myAge;

 

echo ("$retAge - $myAge = $yearsLeft<br>");

echo ("You Have $yearsLeft Years Left!");

?>

</html>

 

The main reason it looks like your script wasn't running was because you had no $ in front of your yearsLeft variable. The only other thing that I really saw is that you were setting yearsLeft to a string because it was enclosed in quotes.

 

yearsLeft="$retAge-$myAge";

 

This would make yearsLeft equal to "70-30" instead of the 40 that you want. Also, you do not need quotes when assigned the initial values to retAge and myAge. Their integers and syntacically should not have quotes. Quotes are reserved, generally speaking, for strings such as "Mary had a little lamb."

 

The remainder of changes that I made were merely syntacical. Let me know if you have any questions about the changes that I made. Glad to help.

  • Author
omg, thanx so very much. If i need anymore help ill know where to come :eek:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.