Author Topic: [SOLVED] Dummy PHP function or a dummny command ?  (Read 813 times)

0 Members and 1 Guest are viewing this topic.

Offline paragkalraTopic starter

  • Irregular
  • Posts: 29
  • Gender: Male
    • View Profile
    • paragkalra.com
[SOLVED] Dummy PHP function or a dummny command ?
« on: January 24, 2009, 02:11:31 AM »
I have following logic in one of my php file:
Quote
if($var)
    echo "";
else
    die("Not defined");

It's working but the problem is that echo in "if" clause is inducing a new line. Does anyone know any dummy php function or a command which will do nothing and will also not insert a new line?

Or is there a way through which I can disable new line using "echo" itself?
Parag.A.Kalra, The Linux Man
http://www.paragkalra.com/
In this world without WALLS and GATES who need WINDOWS! USE LINUX! STOP PIRACY! GO OPEN SOURCE!

Online KingPhilip

  • Global Moderator
  • Fanatic
  • *
  • Posts: 3,099
  • Gender: Male
  • Are you a freak?
    • View Profile
    • MisterPhilip.com
Re: Dummy PHP function or a dummny command ?
« Reply #1 on: January 24, 2009, 02:20:13 AM »
you could always do something like usleep(1), which would "pause" execution for 1ms. That's about the most 'dummy' like function I can think of (maybe like $i = 1, or something like that)

Offline .josh

  • Administrator
  • 'Insane!'
  • *
  • Posts: 13,151
  • Grumpy Old Man
    • View Profile
Re: Dummy PHP function or a dummny command ?
« Reply #2 on: January 24, 2009, 02:26:26 AM »
if you don't want the if condition to do anything if it's true, then just don't use it.


if (!$var) die("Not Defined");


or if you insist on having it but doing nothing, put nothing in it:


if ($var) {
   
// I do nothing, what's the point in living??
} else {
  die(
"Not Defined");
}

Did I help you? Feeling generous? Donate to me! | Donate to phpfreaks!

Offline paragkalraTopic starter

  • Irregular
  • Posts: 29
  • Gender: Male
    • View Profile
    • paragkalra.com
Re: Dummy PHP function or a dummny command ?
« Reply #3 on: January 24, 2009, 02:41:14 AM »
Thanks KingPhilip & Crayon Violent for your suggestions  ...

as a workaround I am already using:
Quote
if(!$var)
    die("Not defined");
Parag.A.Kalra, The Linux Man
http://www.paragkalra.com/
In this world without WALLS and GATES who need WINDOWS! USE LINUX! STOP PIRACY! GO OPEN SOURCE!

Offline .josh

  • Administrator
  • 'Insane!'
  • *
  • Posts: 13,151
  • Grumpy Old Man
    • View Profile
Re: Dummy PHP function or a dummny command ?
« Reply #4 on: January 24, 2009, 10:56:18 AM »
It's not really a workaround if it's how you are supposed to do it...

Did I help you? Feeling generous? Donate to me! | Donate to phpfreaks!

Offline paragkalraTopic starter

  • Irregular
  • Posts: 29
  • Gender: Male
    • View Profile
    • paragkalra.com
Re: [SOLVED] Dummy PHP function or a dummny command ?
« Reply #5 on: January 24, 2009, 11:06:45 AM »
@ Crayon Violent

Yup U are correct...my aim was just to know if there is any dummy function or a command available in php...
Parag.A.Kalra, The Linux Man
http://www.paragkalra.com/
In this world without WALLS and GATES who need WINDOWS! USE LINUX! STOP PIRACY! GO OPEN SOURCE!