WesleyA Posted February 1, 2016 Share Posted February 1, 2016 Where online can I find a good tut about inline php coding? I have practiced it and used it, but I'm not sure what is allowed and I would like to read some more examples. Link to comment Share on other sites More sharing options...
AbigailMenard Posted February 1, 2016 Share Posted February 1, 2016 Hi WesleyA. There are many websites which are dedicated for PHP coding. For example Tutorialspoint.com , codeacademy.com, and specially w3schools. You can get any possible information about PHP here. Good Luck. Link to comment Share on other sites More sharing options...
WesleyA Posted February 1, 2016 Author Share Posted February 1, 2016 I will give an example. The code is a loop, but it doesn't grab the column from the css style sheet. <?php for ($i = 1; $i <= 4 ; $i++ ) { $var = $i; var_dump($var) ?> <span class="<?php $var; ?>" > </span> <?php } ?> changing $var in to something else or renaming the css classes does also not seem to work. is the code as used above good? I'm not sure how to embed php in html attributes, what are the rules? Link to comment Share on other sites More sharing options...
john_jack Posted February 1, 2016 Share Posted February 1, 2016 replace the folowing : <span class="<?php $var; ?>" > with this <span class="<?php echo $var; ?>" > you need to echo the $var ,i supose you have a css class called 1 , 2 , 3 , 4 . Good luck and check this http://www.w3schools.com/php/default.asp Link to comment Share on other sites More sharing options...
WesleyA Posted February 6, 2016 Author Share Posted February 6, 2016 yes, it worked fine adding some php into attribute values. Link to comment Share on other sites More sharing options...
turtlec Posted February 8, 2016 Share Posted February 8, 2016 Please bear in mind when you use inline techniques like these not to mix up your quote. if for instance you were embedding in somethign like <a href="http://www.link">. You would need to use single quotes for the php <a href="http://www.'<?php echo $thelink; ?>' "> Link to comment Share on other sites More sharing options...
dsonesuk Posted February 8, 2016 Share Posted February 8, 2016 (edited) Please bear in mind when you use inline techniques like these not to mix up your quote. if for instance you were embedding in somethign like <a href="http://www.'<?php echo $thelink; ?>' ">Ooohhh no you wouldn't, you would only use single quotes to separate php string from php variable echo '<a href="http://www.'.$thelink.'">'; With non php html inserting php using <a href="http://www.<?php echo $thelink; ?>"> is fine. Edited February 8, 2016 by dsonesuk Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now