Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 2nd June 2006, 23:48
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,034
Thanks: 265
Thanked 151 Times in 131 Posts
Default converting a 10 line cgi to php.

Could some CGI, PHP expert please show me how this small CGI script should look like in PHP?

The CGI script:
Code:
#!/usr/bin/perl
use CGI;

my $cgi = CGI->new();
my @param = $cgi->param();

print"Content-type: text/html\n\n";
for(@param)
{
 my @arr = $cgi->param($_);
 print"$_:".join(':',@arr)."<br>";
}
All I got till now in PHP is:
Code:
<?php

echo "Content-type: text/html\n\n";

?>

Please help.. I'm lost...
Reply With Quote
Sponsored Links
  #2  
Old 3rd June 2006, 09:49
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,146
Thanks: 4
Thanked 55 Times in 51 Posts
Default

You want to loop through an array?
I don't know Perl... but PHP ^^
Reply With Quote
  #3  
Old 3rd June 2006, 13:35
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

I'm no Perl expert either... What does the CGI script do?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #4  
Old 3rd June 2006, 17:16
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,034
Thanks: 265
Thanked 151 Times in 131 Posts
Default

Quote:
Originally Posted by falko
I'm no Perl expert either... What does the CGI script do?
It's some code that will dump/show a variable..

I've now recoded it in the language I know best.. Coldfusion :-)
No need for the PHP code anymore.
Reply With Quote
  #5  
Old 3rd June 2006, 17:20
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,146
Thanks: 4
Thanked 55 Times in 51 Posts
Default

For showing a variable in PHP it's straight-forward:

Quote:
<? echo $var; ?>
Reply With Quote
  #6  
Old 3rd June 2006, 22:02
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

If it's an array, then use
PHP Code:
<?php
print_r
($arr);
?>
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #7  
Old 3rd June 2006, 22:40
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,146
Thanks: 4
Thanked 55 Times in 51 Posts
 
Default

or a foreach ^^

Quote:
foreach($arr as $key => $val) {
echo "Key: $key / Val: $val";
}
or without key:
Quote:
foreach($arr as $val) {
echo "Val: $val";
}
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
log files, rotation and emailing them hairydog2 General 65 11th October 2006 13:18
First Login Error evbim Installation/Configuration 13 6th May 2006 12:19
Downgrade php5 to php4.4.2 llizards Installation/Configuration 4 13th March 2006 23:58
Installation Big issue OpenVZ VPS jbond007 Installation/Configuration 3 7th March 2006 19:40
Ispconfig and Virtuemart shajazzi Installation/Configuration 7 21st February 2006 20:25


All times are GMT +2. The time now is 11:49.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.