PHP populate variable with function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP populate variable with function
# 1  
Old 11-20-2010
PHP populate variable with function

Hi,
I've a php scirpt that calls in an external class. The external class, myClass, has several public and private functions.
There is one public function which derives a value that I want be able to bring it to the main php scirpt. Here is the code.
PHP Code:
....snip....
include 
'myClass.class.php';
$createFile = new myClassFunction();

                echo 
'<div id="preview" style="display:block"><p>Accessing  your link. Please wait.</p>';
                
// still working on this part
                
flush();
// Main Program

            
if ($createFile->DownloadPDF(trim($_POST['userPDFurl'])))
            {
               
//User link is good
               
echo $createFile->GetFileName();  //This is the file user should be able to download
               
echo ($createFile->GeneratePDF('$_POST[quality]')) ? '<p>Success!</p>' '<p>Error generating PDF file!</p>';
            }
            else
            {
               
// Could not reach user link
               
echo '<p>Error downloading PDF!</p>';
            }
 ....
snip.... 
If you notice in above code, I can echo the newly created file name and path 'echo $createFile->GetFileName();'
What I want to do is to put the value from the function to some variable and create a link. Something like this:
PHP Code:
echo'
Here is your file <a href="http://mysite.cc/"$createFile->GetFileName()></a>. Click here 
It doesn't really work, and I link appears messed up.Smilie Can I put $createFile->GetFileName() in to yet another variable and echo that? Smilie

Thank you,
Nitin
# 2  
Old 11-21-2010
Hi,
I figured that my syntax was not entirely correct. Now I can display the entire link as text.
PHP Code:
echo "http://mystie.cc/",$createFile->GetFileName(),"<br />\n"
The comma before and after the function was needed. Smilie
Next step is to make this thing text as a click-able link. But that's another story.

Nitin
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass variable from one function to another function?

updateEnvironmentField() { linewithoutquotes=`echo $LINE | tr -d '"'` b() } I want to pass variable named $linewithoutquotes to another method called b(), which is called from updateEnvironmentField() method. How to do the above requirement with shell script (1 Reply)
Discussion started by: pottic
1 Replies

2. Shell Programming and Scripting

Passing variable value in a function to be used by another function

Hello All, I would like to ask help from you on how to pass variable value from a function that has been called inside the function. I have created below and put the variables in " ". Is there another way I can do this? Thank you in advance. readtasklist() { while read -r mod ver... (1 Reply)
Discussion started by: aderamos12
1 Replies

3. Shell Programming and Scripting

How to pass a function with a variable parameter into another variable?

Hello again :) Am currently trying to write a function which will delete a record from a file. The code currently looks as such: function deleteRecord() { clear read -p "Please enter the ID of the record you wish to remove: " strID ... (2 Replies)
Discussion started by: U_C_Dispatj
2 Replies

4. Shell Programming and Scripting

populate a bash variable from an awk operation

Hi, I'm trying to populate bash script variable, data_size with the size of the largest file in my current directory data_size=$(ls -lS | grep -v "total" | head -1) | awk '{ print $5 }' I've tried adding an echo before the call to awk data_size=$(ls -l | grep -v "total" | head -1) |... (2 Replies)
Discussion started by: mark_s_g
2 Replies

5. Shell Programming and Scripting

populate specified value in csv

Hi, I've requirement of populating two blank column ( 4rth and 6th ) in a csv file with specified value for all the rows having value within the first colmn. I know it can be done with sed, as given in the below command, but i am not sure how pull blank value or specify target column etc or... (11 Replies)
Discussion started by: john_prince
11 Replies

6. Shell Programming and Scripting

running command remotely to populate local variable

If I run this # ssh remote-server 'du -sk /usr/platform/`uname -i`/' 174 /usr/platform/SUNW,Sun-Fire-V245 I get my output just fine, However, if i try to do the same but populate a local variable within my script called for example 'result' #!/bin/ksh result=`ssh remote-server... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

7. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

8. UNIX for Dummies Questions & Answers

passing a variable inside a variable to a function

I would like to know how to pass a variable inside a variable to a function. sample code below -------------- for x in 1 9 do check_null $C$x ##call function to check if the value is null if then echo "line number:$var_cnt,... (2 Replies)
Discussion started by: KingVikram
2 Replies

9. Shell Programming and Scripting

populate variable from remote result

Hi there i am trying to pass the result of a remote command into a variable into my script ie #!/bin/sh var = `ssh remote_box 'uname'` echo $var but all i get back is ./script.sh: var: not found However when i add a -x to put it into diag mode i get the following + ssh... (2 Replies)
Discussion started by: hcclnoodles
2 Replies
Login or Register to Ask a Question