TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Tips & Tricks (http://www.talkphp.com/tips-tricks/)
-   -   Outputting data without print/echo (http://www.talkphp.com/tips-tricks/2386-outputting-data-without-print-echo.html)

TlcAndres 03-01-2008 06:39 PM

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);



Alan @ CIT 03-01-2008 08:13 PM

Can't beat good ol' streams :-)

PHP Code:

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


Alan

ReSpawN 03-01-2008 10:05 PM

It might be kinda lame but there is always var_dump();.
PHP Code:

$myVar 'TalkPHP';
var_dump($myVar); 


Wildhoney 03-01-2008 10:15 PM

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

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

Long live the geniuses.

ReSpawN 03-01-2008 10:17 PM

Quote:

Originally Posted by Wildhoney (Post 11788)
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); 


Salathe 03-01-2008 11:58 PM

PHP Code:

Hello World


ReSpawN 03-02-2008 07:46 PM

Quote:

Originally Posted by Salathe (Post 11800)
PHP Code:

Hello World


...? I don't get it?

StevenF 03-02-2008 08:13 PM

Quote:

Originally Posted by ReSpawN (Post 11843)
...? I don't get it?

He didn't say using only PHP. I guess that what Salathe was getting at.

Salathe 03-02-2008 11:18 PM

It outputs data without using print/echo. Put it in a .php file and try for yourself.

ETbyrne 03-03-2008 01:24 AM

Don't forget sprinf() and fprintf()! :-P

You could also use include(), include_once(), require() , and require_once().

Aaron 03-03-2008 03:39 AM

ummm
PHP Code:


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

  
cout << "Hello World"
  return 
0



ReSpawN 03-03-2008 06:22 AM

Quote:

Originally Posted by StevenF (Post 11845)
He didn't say using only PHP. I guess that what Salathe was getting at.

Scroll three posts up dude.

sketchMedia 03-12-2008 05:30 PM

Quote:

Originally Posted by Aaron (Post 11875)
ummm
PHP Code:

#include <iostream.h> 
using namespace std

int main() 

  
cout << "Hello World"
  return 
0



i lol'd. good ol' std::cout eh?

Nor 03-13-2008 01:36 PM

Quote:

Originally Posted by Salathe (Post 11800)
PHP Code:

Hello World


;) thats funny

Austin6641 03-13-2008 10:33 PM

There is always this:
PHP Code:

<?php
die("Hello World!");
?>

It would cause problems if you wanted to execute code after that though...

Orc 03-13-2008 11:09 PM

PHP Code:

<?= "Hello World." ?>


ReSpawN 03-14-2008 01:41 PM

PHP Code:

<?php exit('TalkPHP'); ?>


martins256 03-25-2008 06:43 PM

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);
?>


Orc 03-26-2008 01:47 AM

Quote:

Originally Posted by martins256 (Post 12789)
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);
?>


So simple yet, so good looking xD

sarmenhb 04-28-2008 05:27 AM

Quote:

Originally Posted by Orc (Post 12805)
So simple yet, so good looking xD

wow i didnt know you can do that with php


All times are GMT. The time now is 01:09 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0