ripkjs Posted April 18, 2009 Share Posted April 18, 2009 $clP = '<img src="imagelink.png" />' Seems to not work, I'm assuming it is because of the nested quotes? Help! Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/ Share on other sites More sharing options...
The Little Guy Posted April 18, 2009 Share Posted April 18, 2009 or the missing semi-colon at the end? Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813293 Share on other sites More sharing options...
soak Posted April 18, 2009 Share Posted April 18, 2009 Looks fine apart from the missing semicolon at the end. Where / how are you trying to use the variable? Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813294 Share on other sites More sharing options...
ripkjs Posted April 18, 2009 Author Share Posted April 18, 2009 oops, yes. it is there in the code, just failed to get it on here. preg_replace("/CLp/", $clP, $getPoints); Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813296 Share on other sites More sharing options...
The Little Guy Posted April 18, 2009 Share Posted April 18, 2009 $clP = '<img src="imagelink.png" />'; echo preg_replace("/CLp/", $clP, $getPoints); It probably isn't working because you are not echoing out the replacement, and what do you have for "$getPoints"? Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813301 Share on other sites More sharing options...
.josh Posted April 18, 2009 Share Posted April 18, 2009 are you assigning the results of preg_replace to anything? It's not the same as preg_match where the results are put in the var specified in the argument. You have to assign the results to a var with normal assignment: // assuming you want to overwrite the same var... $getPoints = preg_replace("/CLp/", $clP, $getPoints); Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813302 Share on other sites More sharing options...
.josh Posted April 18, 2009 Share Posted April 18, 2009 $clP = '<img src="imagelink.png" />'; preg_replace("/CLp/", $clP, $getPoints); The reason it is not working, is because your preg_replace can not find "CLp" in the string in your variable. no...the 2nd argument for preg_replace is what you want to replace the pattern matched in the 3rd argument with. Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813305 Share on other sites More sharing options...
The Little Guy Posted April 18, 2009 Share Posted April 18, 2009 $clP = '<img src="imagelink.png" />'; preg_replace("/CLp/", $clP, $getPoints); The reason it is not working, is because your preg_replace can not find "CLp" in the string in your variable. no...the 2nd argument for preg_replace is what you want to replace the pattern matched in the 3rd argument with. Yeah I realized that before your post, so I modified it! Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813307 Share on other sites More sharing options...
ripkjs Posted April 18, 2009 Author Share Posted April 18, 2009 I got it working, i think i was using double quotes: $clP = "<img src="imagelink.png" />"; Brain fart... Works okay now with single quotes. We won't tell anyone about this mmk!? Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813308 Share on other sites More sharing options...
The Little Guy Posted April 18, 2009 Share Posted April 18, 2009 I got it working, i think i was using double quotes: $clP = "<img src="imagelink.png" />"; Brain fart... Works okay now with single quotes. We won't tell anyone about this mmk!? I don't see how that would work... I see an error... using that would make "imagelink.png" no longer part of the string... Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813313 Share on other sites More sharing options...
ripkjs Posted April 18, 2009 Author Share Posted April 18, 2009 Originally in the code I was using the double quotes around the image tag, but when I rewrote the variable here I used single quotes. Stupid mistake, and you all got to witness it! Grats on your 4k post also, Little Guy! Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813316 Share on other sites More sharing options...
.josh Posted April 18, 2009 Share Posted April 18, 2009 Most people like to shove their mistakes under the rug and try to erase the fact that it happened. I wear my pin my stupid mistakes on my shirt for all to see, like a boyscout's sash full of badges. See that way, I can prove I'm not talking out my ass when I say I know something. I have the mistake to prove that I fucked up and learned, so you don't have to just take my word for it. Quote Link to comment https://forums.phpfreaks.com/topic/154660-solved-correct-way-to-define-this-variable/#findComment-813325 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.