Subroutines in php?

A

Anonymous

Guest
Hi,
I am doing some programming stuff with php. My 1st project is a little *.csv-converter, which works great.
I now decided to add a new feature to the converter. It should now also convert *.xls files. The php script just takes a look at the extension and "jumps" to the right part of the script.. (I have to process with a csv file different than with a *.xls)... well that's the theorie.

In other programming languages I had Labels, Rownumbers, all kind of possibilities to jump to subroutines.
I didnt find anything that would work for php the same way.
So, question.. can I define a label where I can jump to (i.e. gosub, goto,..) or do I have to put all the code in a big IF/ELSE statement or redirect to 2 different pages (1 to convert the csv, other for the xls) ?

thx 4 your help
regards
Frank
 
From your post, I feel safe assuming that your past programming experience is in BASIC, VB, COBOL, or similar once-useful but now crufty languages. Which is unfortunate. The "GOTO" programming paradigm is lousy, and was doomed from the start. Sadly, it continues to be promoted on platforms like VB and (ack!) C#.

What PHP and all other modern programming languages have is the "function" (or "method", depending on who you ask). Get to know it. It is your friend.
 
yeah right.. qbasic, visual basic.. even assembler & turbo pascal (long time ago..)


In all these languages I got the clue how they work..
with php I dont know exactly, I still ask myself how the browser interprets the code..

Of course I know the "function" command, although I never used it..
and with this project I kind of have trouble putting code elements in a function...

I guess I search for the "method" command, never heard of it.

thanks,
you are doing all a great job!
frank
 
The browser does not interpret PHP; the server interprets it before sending it to the browser.

It sounds to me like you could benefit from reading the documentation (start at PHP.net -- there's a great Introductory Tutorial) and perhaps purchasing a good PHP book or reading a few tutorials.
 
Back
Top