Printing <?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
InSion
Forum Newbie
Posts: 11
Joined: Thu Oct 21, 2004 7:20 am

Printing <?

Post by InSion »

Easy question... difficult answer?

Is there anyway to print the code "<?" ??... I don´t think

Code: Select all

<?php echo "<?"; ?>
will work..... also, I need the code to be exactly <? I can´t use codes like... <...

help will we VERY appreciated. :D
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Rather annoying problem...
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Re: Printing <?

Post by BDKR »

InSion wrote: I can´t use codes like... <...
Why?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

i guess not everything that is outputted by php is (x)(ht)ml ;)


this is weird:

Code: Select all

echo "zut " . "<" . "?" . " bar";
outputs:

zut
InSion
Forum Newbie
Posts: 11
Joined: Thu Oct 21, 2004 7:20 am

Post by InSion »

I can´t use those codes becouse I want the code to be written in html code exactly <? ?>.... I would write it inside a javascript function and the idea is that that piece of code is executed each time the javascript function is called... now I´m thinking.... being javascript a client-side languaje is that possible?? :cry:

The really proble I´m dealing with is a form which is used to make modifications to some places information of Ushuaia city, when you decide to modify, i.e. "Pizza Center" a form with it´s name, address, and all the information will be shown, taking it from a mysql database. One of the fields is the phone prefix.

I get "02901" from my database and I have to show it from a dropdown (I make it in a php function that gets the options from a mysql table)selected... It´s very difficult to explain, I can show the code here or maybe you wanna me to place it in internet so you can try it...
InSion
Forum Newbie
Posts: 11
Joined: Thu Oct 21, 2004 7:20 am

Post by InSion »

timvw wrote:i guess not everything that is outputted by php is (x)(ht)ml ;)


this is weird:

Code: Select all

echo "zut " . "<" . "?" . " bar";
outputs:

zut
mm... maybe with something like

Code: Select all

<?php echo "zut" . "<" . "&nbsp;" . "\d" . "?" ?>
Where "\d" is a delete-one-char code?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

that outputs: zut<&nbsp;\d?

i (and the op) really want <?
InSion
Forum Newbie
Posts: 11
Joined: Thu Oct 21, 2004 7:20 am

Post by InSion »

timvw wrote:that outputs: zut< \d?

i (and the op) really want <?
Yes, \d should be remplaced with a special code from php used to delenete one char, I think there exists one, but don´t know which is it
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

InSion wrote:I can´t use those codes becouse I want the code to be written in html code exactly <? ?>....
So you merely want it this way as opposed to needing it this way for some valid reason? What's wrong with using the special character designations?
InSion
Forum Newbie
Posts: 11
Joined: Thu Oct 21, 2004 7:20 am

Post by InSion »

BDKR wrote:
InSion wrote:I can´t use those codes becouse I want the code to be written in html code exactly <? ?>....
So you merely want it this way as opposed to needing it this way for some valid reason? What's wrong with using the special character designations?
Just want the code to be <? ?>... The reason is very crazy and difficult to explain... I think that if I could write that I won´t anyway be able to do what i want... so I´m trying something different.

Anyway I think this finished being an interesant post, becouse I really want to know if that is possible in any way...
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Hmmm.... . About the only thing I can think of all the top of my head is to use the code tags around them, but then they can't be controlled by style sheets (to the best of my tired not enough sleep thinking at the moment.

Good luck otherwise. I'm not sure I can see another way around the issue.

Cheers
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

this works

Code: Select all

echo '<?php code ?>';
// or 
echo '<? code ?>';
seems you gotta use a closeing tag ?> or it wont though.....


you could also make a file with nothing in it but the open tag, then either

Code: Select all

echo file_get_contents('open_tag_file.txt');
// or
readfile('open_tag_file.txt');
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

untested but try using some language that does not understand php code

<script language="javascript">
document.write("<");
document.write("?");
</script>

Or look trough HTML - maybe something usefull will come up.
Post Reply