Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a page named ChangeApprovalInfo.php - It has a function called Row_Rendered as follows;

function Row_Rendered() {

    // To view properties of field class, use:
    //var_dump($this-><FieldName>);

    $RecordOwner = $this->RequestUser->CurrentValue;  
        echo $RecordOwner;
} 

Echoing $RecordOwner gets me the data I will need for a sql query on another page....

I have another page called ChangeApprovalEdit.php - This page has

<?php include_once "ChangeApprovalinfo.php" ?>

at the top of the file.

ChangeApprovalEdit.php has a function where I need the $RecordOwner variable as defined in ChangedApprovalInfo.php

If I add "echo $RecordOwner" on the ChangeApprovalEdit.php page, I get an error saying it's an unknown variable. My understanding is that I need to "make it global" or some such business. I know very little about PHP and the pages I am editing are long and complex. (to me, at least)

  • What do I need to do? I know that the information I have provided might not be enough to answer the question. I don't know enough to even know exactly what I need to ask. If more information is needed, I will edit and follow up.

pastebin of the files

ChangeApprovalInfo.php = http://pastebin.com/bSRM1wwN
ChangeApprovalEdit.php = http://pastebin.com/AStG9pqb

EDIT: Changing Row_Rendered to this seems to be more effective. I'm having trouble seeing WHERE I can later echo this variable... but I'm getting somewhere with this...

function Row_Rendered() {
    // To view properties of field class, use:
    //var_dump($this-><FieldName>);
    $GLOBALS['RecordOwner'] = $this->RequestUser->CurrentValue;  
} 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
154 views
Welcome To Ask or Share your Answers For Others

1 Answer

Don't echo variables from functions, which just outputs them to the standard output. return them from the function so you can use the value elsewhere as well.

function Row_Rendered() {
    $RecordOwner = $this->RequestUser->CurrentValue;  
    return $RecordOwner;
} 

Then instead of

$obj->Row_Rendered();

use

echo $obj->Row_Rendered();

and if you want to use the value elsewhere, use

$value = $obj->Row_Rendered();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...