/    Sign up×
Community /Pin to ProfileBookmark

help with generated php

hi,

im trying to figure out what php code is returned with this function

[CODE] function xxx_chklist_mst($mst, $name, $checkrec) {
$list = “<table style=”width: auto;margin: 0px;”><tr>n”;
$f = file($mst);
foreach($f as $line){
$line = chop($line);
if($line==’–‘){
$list .= “</tr><tr>n”;
} elseif($line==’++’) {
$list .= “<td style=”width: auto;padding: 0px;margin: 0px;border-width: 0px;background-color: transparent;”><br></td>”;
} else {
$rec = explode(‘:’, $line);
$checked = ”;
if(isset($checkrec[$rec[0]])) $checked = ‘ checked’;
$list .= “<td style=”width: auto;padding: 0px;margin: 0px;border-width: 0px;background-color: transparent;”><input name=”.$name.$rec[0].” type=checkbox value=””.$rec[1].”””.$checked.”>”.$rec[1].”&nbsp;&nbsp;</td>n”;
}
}
$list .= “</tr></table>n”;
return $list;
}[/CODE]

and you call that function like this in the template

[CODE]<?php echo xxx_chklist_mst(“./php/config/SONOTA_MST.php”, “HID-SONOTA_ID”, $rec_syumi); ?>[/CODE]

it should return among the html code, some php like this which is what i need to get

[CODE][…] <?php if(!$obj_hid[‘SONOTA_ID010′]==’0’){echo ‘ checked’;} ?>[…][/CODE]

but i cant tell what is exactly returned within the IF statement. Can you please give me a hand?

Thank you.

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@Phill_PaffordMar 11.2009 — You could try to use the highlight_file()

[code=php]
echo highlight_file(xxx_chklist_mst("./php/config/SONOTA_MST.php", "HID-SONOTA_ID", $rec_syumi),true);
[/code]
Copy linkTweet thisAlerts:
@supercainauthorMar 12.2009 — thank you, but nothing happens by doing that... are you sure you can use highlight_file() with a function within? also, im not sure if this function will do what im looking for. I need something that returns the php that is generated before being converted into html. Im talking about this part specifically

if(isset($checkrec[$rec[0]])) $checked = ' checked';

it generates another php code for each statement, something SIMILAR to this

<?php if(!$obj_hid['SONOTA_ID010']=='0'){echo ' checked';} ?>

but its not the right value because inserting this manually wont work. The !$obj_hid['SONOTA_ID010']=='0' part must be something else. I tried !$obj_hid['SONOTA_ID010']=='1' [U]and[/U] !$obj_hid['SONOTA_ID010'] but didnt work either.
Copy linkTweet thisAlerts:
@Phill_PaffordMar 12.2009 — you could try passing the functions return to the highlight_file command
Copy linkTweet thisAlerts:
@supercainauthorMar 12.2009 — sorry how? i tried with the code you posted but nothing happens.
Copy linkTweet thisAlerts:
@Phill_PaffordMar 12.2009 — [code=php]
// Just to see what prints out
echo "<pre>" . $checkrec[$rec[0]] . "</pre><br />n";

// AND /OR
$output = $checkrec[$rec[0]];
highlight_string($output, true);
[/code]
Copy linkTweet thisAlerts:
@supercainauthorMar 13.2009 — hi,

it only prints out this

<pre></pre>

thats all! im really having a hard time with this. Im not the one who coded this so its hard to get it cracked.
Copy linkTweet thisAlerts:
@Phill_PaffordMar 13.2009 — [code=php]
// Your function
function xxx_chklist_mst($mst, $name, $checkrec) {
$list = "<table style="width: auto;margin: 0px;"><tr>n";
$f = file($mst);

foreach($f as $line) {
$line = chop($line);
if($line=='--') {
$list .= "</tr><tr>n";
} elseif($line=='++') {
$list .= "<td style="width: auto;padding: 0px;margin: 0px;border-width: 0px;background-color: transparent;"><br></td>";
} else {
$rec = explode(':', $line);
$checked = '';
if(isset($checkrec[$rec[0]])) $checked = ' checked';
$list .= "<td style="width: auto;padding: 0px;margin: 0px;border-width: 0px;background-color: transparent;"><input name=".$name.$rec[0]." type=checkbox value="".$rec[1].""".$checked.">".$rec[1]."&nbsp;&nbsp;</td>n";
}
}
$list .= "</tr></table>n";
return $list;
}

$output = xxx_chklist_mst("./php/config/SONOTA_MST.php", "HID-SONOTA_ID", $rec_syumi);

echo "<pre>" . $output . "</pre>"; // <-- This will output the code passed back from the function

[/code]
Copy linkTweet thisAlerts:
@supercainauthorMar 16.2009 — hi,

but by doing that, i only get the final code in HTML. I need the code in php before it is parsed into HTML so i can put it myself manually. The function outputs something very SIMILAR (but not equal) to this

<?php if(!$obj_hid['SONOTA_ID010']=='0'){echo ' checked';} ?>

before its parsed into html like this

checked <- in case the value exists in the database

<- (nothing) in case the value doesnt exist in the database


The browser will never show me php before its parsed into html. Is there anyway to do it with another program maybe?

Thank you.
Copy linkTweet thisAlerts:
@supercainauthorMar 16.2009 — Never mind, i quit trying to get the parsed php before it gets parsed into html. I just changed the function itself to print the html i wanted.

Thank you anyway.
×

Success!

Help @supercain spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...