![]() |
| ||
| using statements in user defined functions is there a way to create a function that uses values from the statement inside of brackets. ex. myFunction(){
if not, what i am trying to do is get a html tag and check/modify without having it inside of a variable or echo tag. for example, i want to do the equivilent of this: <?php i do not want to use javascript for this although it would be easier. thanks! |
| ||
| Re: using statements in user defined functions Although the syntax of your example is incorrect, yes, you can create a function to manipulate the data. eg. <?php |
| ||
| Re: using statements in user defined functions Quote:
<?phpthen check if the configuration applies to it and then return the altered html. i dont have issues with the "meat" of the function. i will be constantly changing the data that i want to run through checkConfig() so putting the data in a variable ex. <?php $data="<input....."; ?> would not be efficient or helpful. maby you can get the same results with a class? |
| ||
| Re: using statements in user defined functions Anything that is outside PHP tags is not available to PHP to manipulate. Its hard to understand exactly what you are trying to do - why do you wish to manipulate the HTML? What is "the configuration". What is "the data contained in a statement"? Why not just have PHP output the correct HTML based on your "configuration"? Matti Ressler Suomedia |
| ||
| Re: using statements in user defined functions i wrote the below script but it is not done note: what i will eventually write is not as basic as just bolding the text. i just put that there as an example. example check function <?php example data: <?php class data{function get(){ ?>
This is the text that will go through the check() function <?php } function ret($string){echo $string;}}$data = new data(); ?> |
| ||
| Re: using statements in user defined functions i dont need to "technicaly" or "directly" manipulate the html, i just need to grab the html and then echo it modified. let me rephrase this... when i run this.... <?php function test(){ ?> data <?php } ?> everytime a run test() in php, the html outside of the tags is outputted (data) i want to take the data in test() and be able to do anything with it that i could do with a normal string. i DO NOT want to do this. echo "html here.."; or <?php $data = <<<_ html here... _; echo $data; ?> i want to have the text outside of the php tags, grab it, and put it into string so i can echo it later. I cant quite phrase why i need to have the origional html outside of the php tags but you will just have to trust me that it is what i want. I dont know if i am on the right track with using a function to get the data, but i cant find any other way to get it, i have tried doing something like this: <?php function test(){ return ?>html here...<?php ; } ?> but nothing is returned. Thanks for your help so far. |
| ||
| Re: using statements in user defined functions i am sorry for the triple post, i truly am... but i solved this issue after a day's work of googling and thought i could save people the same trouble by posting my solution here. i guess a moderator could delete by past two posts or something. any way... i discovered the use of buffering data before it reaches the browser. <?php |
| ||
| Re: using statements in user defined functions Perhaps something like this? <?php Matti Ressler Suomedia |
| ||
| Re: using statements in user defined functions thanks! that does work simpler than my method. |
| All times are GMT -4. The time now is 11:12 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC