TalkPHP
 
 
Account Login
Latest Articles
» cURL Basics
» Securing your PHP applications Part 1
» The way the function rolls
» Database Abstraction with Zend_Db - Part 2
» CSRF POST Token Protection
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 03-01-2008, 05:39 PM   #1 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 265
Thanks: 2
TlcAndres is on a distinguished road
Default Outputting data without echo/print

Well I'd like to see how inventive you all are in outputting data to the screen without using echo or print or C hooks (Alan)


Here goes my try

PHP Code:

function newecho($text)
{
     
$path $_SERVER['DOCUMENT_ROOT'] . '/file.html';
     
file_put_contents($path,$text);
     include_once(
$path);

TlcAndres is offline  
Reply With Quote
Old 03-01-2008, 07:13 PM   #2 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 482
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Can't beat good ol' streams

PHP Code:
function newecho($text)
{
    
$output fopen('php://output''w');
    
fputs($output$text);

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 03-01-2008, 09:05 PM   #3 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 393
Thanks: 46
ReSpawN is on a distinguished road
Default

It might be kinda lame but there is always var_dump();.
PHP Code:
$myVar 'TalkPHP';
var_dump($myVar); 
__________________
The Addict :: Addicted to (talk)PHP!
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
The Following User Says Thank You to ReSpawN For This Useful Post:
Yoosha (06-04-2008)
Old 03-01-2008, 09:15 PM   #4 (permalink)
TalkPHP Loves You
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Nottingham
Posts: 1,419
Thanks: 68
Wildhoney is on a distinguished road
Default

If we're going to be lame then there's printf, too!

php Code:
printf('%s', 'TalkPHP');

Long live the geniuses.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 03-01-2008, 09:17 PM   #5 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 393
Thanks: 46
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
If we're going to be lame then there's printf, too!

php Code:
printf('%s', 'TalkPHP');

Long live the geniuses.
Damn it, you beat me to it.
PHP Code:
$name 'TalkPHP';
$threads 1365;
$posts 10486;
$members 1892;

$myString "%1\$s current stats: Threads: %2\$s, Posts: %3\$s, Members: %4\$s";

printf($myString$name$threads$posts$members); 
__________________
The Addict :: Addicted to (talk)PHP!
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-01-2008, 10:58 PM   #6 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 613
Thanks: 2
Salathe is on a distinguished road
Default

PHP Code:
Hello World
__________________
Salathe is offline  
Reply With Quote
The Following 2 Users Say Thank You to Salathe For This Useful Post:
Nor (03-13-2008), Yoosha (06-04-2008)
Old 03-02-2008, 06:46 PM   #7 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 393
Thanks: 46
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
PHP Code:
Hello World
...? I don't get it?
__________________
The Addict :: Addicted to (talk)PHP!
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-02-2008, 07:13 PM   #8 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 78
Thanks: 49
StevenF is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
...? I don't get it?
He didn't say using only PHP. I guess that what Salathe was getting at.
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote
Old 03-02-2008, 10:18 PM   #9 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 613
Thanks: 2
Salathe is on a distinguished road
Default

It outputs data without using print/echo. Put it in a .php file and try for yourself.
__________________
Salathe is offline  
Reply With Quote
Old 03-03-2008, 12:24 AM   #10 (permalink)
The Acquainted
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 108
Thanks: 14
ETbyrne is on a distinguished road
Default

Don't forget sprinf() and fprintf()!

You could also use include(), include_once(), require() , and require_once().
__________________
There is no place like 127.0.0.1
ETbyrne is offline  
Reply With Quote
Old 03-03-2008, 02:39 AM   #11 (permalink)
The Addict
 
Join Date: Dec 2007
Location: In my basement
Posts: 313
Thanks: 43
Aaron is on a distinguished road
Default

ummm
PHP Code:

#include <iostream.h> 
using namespace std
 
 
int main() 

  
cout << "Hello World"
  return 
0

Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 03-03-2008, 05:22 AM   #12 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 393
Thanks: 46
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by StevenF View Post
He didn't say using only PHP. I guess that what Salathe was getting at.
Scroll three posts up dude.
__________________
The Addict :: Addicted to (talk)PHP!
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-12-2008, 05:30 PM   #13 (permalink)
The Addict
Advanced Programmer Top Contributor Good Samaritan 
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 339
Thanks: 19
sketchMedia is on a distinguished road
Default

Quote:
Originally Posted by Aaron View Post
ummm
PHP Code:
#include <iostream.h> 
using namespace std

int main() 

  
cout << "Hello World"
  return 
0

i lol'd. good ol' std::cout eh?
__________________
There's nothing an agnostic can't do if he doesn't know whether he believes in anything or not
sketchMedia is offline  
Reply With Quote
Old 03-13-2008, 01:36 PM   #14 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
PHP Code:
Hello World
;) thats funny
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 03-13-2008, 10:33 PM   #15 (permalink)
The Visitor
 
Austin6641's Avatar
 
Join Date: Dec 2007
Posts: 1
Thanks: 0
Austin6641 is on a distinguished road
Default

There is always this:
PHP Code:
<?php
die("Hello World!");
?>
It would cause problems if you wanted to execute code after that though...
Austin6641 is offline  
Reply With Quote
Old 03-13-2008, 11:09 PM   #16 (permalink)
Orc
The Gregarious
 
Orc's Avatar
 
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
Orc is on a distinguished road
Default

PHP Code:
<?= "Hello World." ?>
__________________
Wax on, Wax off
Orc is offline  
Reply With Quote
Old 03-14-2008, 01:41 PM   #17 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 393
Thanks: 46
ReSpawN is on a distinguished road
Default

PHP Code:
<?php exit('TalkPHP'); ?>
__________________
The Addict :: Addicted to (talk)PHP!
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-25-2008, 06:43 PM   #18 (permalink)
The Wanderer
 
martins256's Avatar
 
Join Date: Mar 2008
Posts: 6
Thanks: 0
martins256 is on a distinguished road
Default

PHP Code:
<?php
header 
("Content-type: image/png");
$im = @imagecreatetruecolor(5120)
      or die(
"Cannot Initialize new GD image stream");
$text_color imagecolorallocate($im255255255);
imagestring($im253,  "Talk"$text_color);
$text_color imagecolorallocate($im24612248);
imagestring($im2293,  "PHP"$text_color);
imagepng($im);
imagedestroy($im);
?>
martins256 is offline  
Reply With Quote
Old 03-26-2008, 01:47 AM   #19 (permalink)
Orc
The Gregarious
 
Orc's Avatar
 
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 734
Thanks: 153
Orc is on a distinguished road
Default

Quote:
Originally Posted by martins256 View Post
PHP Code:
<?php
header 
("Content-type: image/png");
$im = @imagecreatetruecolor(5120)
      or die(
"Cannot Initialize new GD image stream");
$text_color imagecolorallocate($im255255255);
imagestring($im253,  "Talk"$text_color);
$text_color imagecolorallocate($im24612248);
imagestring($im2