Online/offline

Online offline checker

Page 1 of 1

14 Replies - 1321 Views - Last Post: 05 January 2008 - 10:59 AM Rate Topic: -----

#1 nutter  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 03-November 07

Online/offline

Post icon  Posted 03 January 2008 - 10:17 AM

my code
<?php
$x = "1";
if (x==1){
echo "online";
}else{
echo "offline";
};
?>



what i am trying to do is get when x=1 the txt to say online
but n e thing else then it says offline
problem is that it only displays offline nomatter what x is
anyhelp?
Is This A Good Question/Topic? 0
  • +

Replies To: Online/offline

#2 dontKnowJava  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 221
  • Joined: 29-September 07

Re: Online/offline

Posted 03 January 2008 - 10:36 AM

take quotes off 1. just make it $x = 1; and add $ in front of x in if statement if ($x==1){

This post has been edited by dontKnowJava: 03 January 2008 - 10:39 AM

Was This Post Helpful? 0
  • +
  • -

#3 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Online/offline

Posted 03 January 2008 - 10:54 AM

I swear, people just don't pay attention.

The problem is not the the quotation marks. The problem is that there is no $ in front of the x in the if statement.

There could also be a problem with the ; after the last } of the if..else block. Don't know, but it's not necessary.
Was This Post Helpful? 0
  • +
  • -

#4 nutter  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 03-November 07

Re: Online/offline

Posted 03 January 2008 - 11:07 AM

thank you
i remember now i put the x witout $ bcoz u fo it like that in c++ keep gettin them convused ll
so thanks for your help
i am also unshure bout last ;
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Head MFIC
  • member icon

Reputation: 5066
  • View blog
  • Posts: 26,449
  • Joined: 10-May 07

Re: Online/offline

Posted 03 January 2008 - 11:13 AM

Quote

I swear, people just don't pay attention.

Too soon after new years. Still have the party-left-overs.

<?php
  $status="offline";
  $x = 1;
  if ($x==1) $status="online";
  printf("%s\n",$status);
?>


This post has been edited by no2pencil: 03 January 2008 - 11:16 AM

Was This Post Helpful? 0
  • +
  • -

#6 darklighter  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 05-January 08

Re: Online/offline

Posted 05 January 2008 - 08:56 AM

View Postno2pencil, on 3 Jan, 2008 - 11:13 AM, said:

Quote

I swear, people just don't pay attention.

Too soon after new years. Still have the party-left-overs.

<?php
  $status="offline";
  $x = 1;
  if ($x==1) $status="online";
  printf("%s\n",$status);
?>



Lol pencil, your code would confuse the crap out of newbies.

Just let them go with this until they get better:
<?php
  $x = '1';
  if ($x=='1'){
		echo "online";
  }else{
		echo "offline";
  }
?>


Was This Post Helpful? 0
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Online/offline

Posted 05 January 2008 - 09:04 AM

Why would it confuse them? seems pretty mundane.
Was This Post Helpful? 0
  • +
  • -

#8 darklighter  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 05-January 08

Re: Online/offline

Posted 05 January 2008 - 09:08 AM

Noobs, have no idea what printf is, nor what "%s\n" does.
Think back to your first day as a coder :)

Especially in php i find it necessary to always show the easy way, because users always go back to edit their code later.

It seems to me most heavy duty programmers write their code using short variable names, and structure for their ability level when newbies really have no idea how to work with that. I always try writing my code "stupid proof" :)
Was This Post Helpful? 0
  • +
  • -

#9 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Online/offline

Posted 05 January 2008 - 09:12 AM

I do remember my first day as a coder...and using references when I needed them. New programmers may not be as 'stupid' as you seem to think - otherwise they'd never develop into talented developers, correct?
Was This Post Helpful? 0
  • +
  • -

#10 darklighter  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 05-January 08

Re: Online/offline

Posted 05 January 2008 - 09:31 AM

View PostAmadeus, on 5 Jan, 2008 - 09:12 AM, said:

I do remember my first day as a coder...and using references when I needed them. New programmers may not be as 'stupid' as you seem to think - otherwise they'd never develop into talented developers, correct?


Lol, i dunno man, my company's been looking for good programmers to join us.
We find people who claim 3-4 years php/frontend experience and they don't even know styling/css (more frontend) and they often don't kow OOPHP, nor how to properly use functions.
Hell, i doubt they even knew what the difference is between print and echo, heh.

I assume people are dumb until they prove me otherwise, this way they learn if they don't know stuff and they find my help easy if they're not dumb :)
Was This Post Helpful? 0
  • +
  • -

#11 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Online/offline

Posted 05 January 2008 - 09:42 AM

View Postdarklighter, on 5 Jan, 2008 - 11:31 AM, said:

Lol, i dunno man, my company's been looking for good programmers to join us.
We find people who claim 3-4 years php/frontend experience and they don't even know styling/css (more frontend) and they often don't kow OOPHP, nor how to properly use functions.
Hell, i doubt they even knew what the difference is between print and echo, heh.

In that case, I would suggest your company is either not offering enough money, or targeting the wrong talent pool. Functions are basic knowledge, and anyone with 2-3 WEEKS of experience would know how to use them.

Quote

I assume people are dumb until they prove me otherwise, this way they learn if they don't know stuff and they find my help easy if they're not dumb :)

Well, I can't agree with that approach - it seems guaranteed to offend if you treat everyone as dumb, but to each his own, I suppose.
Was This Post Helpful? 0
  • +
  • -

#12 no2pencil  Icon User is offline

  • Head MFIC
  • member icon

Reputation: 5066
  • View blog
  • Posts: 26,449
  • Joined: 10-May 07

Re: Online/offline

Posted 05 January 2008 - 09:45 AM

I've found the best way to learn new (& usefull) technologies is to actually use it.

Granted a noob may not know what printf is. But if they know what php.net is, they'll soon find out.
Was This Post Helpful? 0
  • +
  • -

#13 darklighter  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 05-January 08

Re: Online/offline

Posted 05 January 2008 - 09:47 AM

Heh, my company seeks good talent, it's the people applying who just aren't good.

As far as offending people, in order to be a leader of sheep we must be sheep ourselves.
If they cannot be meek and accept that things written simply are easier to understand and are not meant to offend but to teach and enhance their skills, then that's their problem.

I write code that's easy to follow and read, and btw, most people don't know how to properly use functions for at least 6 months or so because they start coding using someone else's crappy code written 5 years ago and by the time they realize it's crap, 6 months have gone by and hopefully they'll have met someone with more experience to teach them proper coding.

I'd say 90% of so-called coders out there are just script kiddies and don't actually know how to write code from scratch and we can't teach them by tossing our complex code at them. They have to learn by looking at easy code and then slowly improving their skill.

Don't you tend to look back at your old code and go "damn, my old code sucks" ?
It's only when we improve our skills that we realize how unskilled we were before.
Was This Post Helpful? 0
  • +
  • -

#14 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Online/offline

Posted 05 January 2008 - 09:53 AM

Again, it sounds like your company is targeting self taught coders, as opposed to developers. Perhaps if you insisted on some formal education in software development as pre requisite for applying, the talent pool may improve. Anyone who has had any sort of development education would understand functions long before the 6 month mark.

For the record, I stated NOT that your habit of writing easy to understand simple code that would offend - it's your attitude. That's simply my opinion, however, and is no more or less valid that any other. A moot point anyway, since I'm not a new programmer, and won't be subjected to it.
Was This Post Helpful? 0
  • +
  • -

#15 darklighter  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 05-January 08

Re: Online/offline

Posted 05 January 2008 - 10:59 AM

lol, fine, you win :-D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1