Jump to content

Recommended Posts

firstly, I remember you, and you are completely getting the wrong concept of these 'token's they are not for USE in a script they are used in DEBUGGING scripts, E.G. "Unexpected T_OPEN_TAG in whateverphpfile.php at line 17"

 

You're looking to output php snippets inside of php, now I have recommended you use nowdoc or heredoc

 

echoing, but you think adding the extra 2 lines is an inconvenience and makes it look 'sloppy' well, there is no other way, you NEED to echo to output, or not echo at all and close the php tag, and type out the actual code..

 

e.g.

 

<?php
yadayada
?><php
echo "hey!";
?><?php
yadayadayada
?>

 

I have just looked at the link I supplied, and noticed that nowdoc apparently only works in 5.2.9 which I don't quite understand, coz otherwise I really wouldn't know about it unless I looked it up b4 and don't remember..

 

but heredoc will 'course render any variables and such.. so thats not that great, guess you're stuck echoing it manually :)

 

or go with a database and just select it out as text by default, then echoing text is not that hard :)

Link to comment
https://forums.phpfreaks.com/topic/147939-solved-php-tokens/#findComment-776455
Share on other sites

You have never provided information about the overall goal you are trying to accomplish, only generic bits and pieces about what you are trying to do at a particular point, so you have never gotten a real good answer on how to do it.

 

I suspect you should be looking at a template system - http://www.smarty.net/

Link to comment
https://forums.phpfreaks.com/topic/147939-solved-php-tokens/#findComment-776457
Share on other sites

Is there really no alternative? I really hate to output to echo or NOWDOC. I do know the concept of tokens and I understand it is not to be manipulated just any way. However, I wish to do some experimentation so I can get the PHP interpreter to interpret the scripts according to how I want it to work.

 

All in the name of experimentation and trial error. In the case no one know what I wish to achieve, let me make it more clearer

 

i.e. <?php echo <?+ echo "Yeah I got this echoed" +?> ?>

 

I wish to tell the interpreter to interpret whatever is within <?+ +?> and not within <?php ?>. Thus I need to manipulate T_OPEN_TAG to bypass <?php tags or if needed to override the token for '?>'

 

I apologise because the topic back then I posted was quite old (about 5-6 pages back )and I did not get it solved thus I wish to rephrase what I want to achieve. =)

Link to comment
https://forums.phpfreaks.com/topic/147939-solved-php-tokens/#findComment-776461
Share on other sites

well bro, you can't =\ I don't think atleast..

 

but I'll rephrase your question in this post and maybe a guru will be some help to you..

 

my friend here wants to know how, if possible, he could sort of 'create' a php tag, which automatically outputs the containing block of code, rather than evaluating it.. for example

 

he'd have

 

<?php+
echo "hey!":
$abc = 123;
echo max((ceil($abc * $abc) / .5),1);
?>

 

and he'd want that block of code to RETURN or OUTPUT

 

<?php
echo "hey!":
$abc = 123;
echo max((ceil($abc * $abc) / .5),1);
?>

 

to the command line and or web browser..

 

 

Link to comment
https://forums.phpfreaks.com/topic/147939-solved-php-tokens/#findComment-776467
Share on other sites

I just don't get why you are trying to reinvent the wheel? Whats the point? Your gonna end up with the same result in the end?

 

Actually I am not trying to reinvent the wheel. I am just doing some experimentation though it may not be a practical solution. At the same time, I can also understand how php parsing works. Thus, I need some help on where in the php core files can I edit the T_OPEN_TAG to '<?+' for example.

Link to comment
https://forums.phpfreaks.com/topic/147939-solved-php-tokens/#findComment-778036
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.