0

I have the following in a block where the text format is PHP code. For some reason the php is just stripped out when I view the page.

<a href="<?php print base_path(); ?>node/add/f2?edit[field_f2][und]=<?php print arg(2); ?>">New</a>
1
  • What order are your filters in. Check the text format and make sure php filter is first. Otherwise the html filter or somethign else may be stripping it out. Commented Feb 12, 2013 at 18:50

3 Answers 3

1

You have a mismatched tag:

<a href="<?php print base_path(); ?>/node/add/f2?edit[field_f2][und]=<?php print arg(2); ?>"New</a>

Should be:

<a href="<?php print base_path(); ?>/node/add/f2?edit[field_f2][und]=<?php print arg(2); ?>">New</a>

Notice the extra > before the "New"

Sign up to request clarification or add additional context in comments.

Comments

1

Besides enabling the 'PHP Filter' module and setting the correct permissions, you also need to edit the format type here:

/admin/config/content/formats/php_code

Tick the 'Roles' you want to have access, and tick the 'PHP evaluator' filter option.

Comments

0

There is a ; missing after print base_path().
It should be print base_path();

5 Comments

This isn't required in this case. In PHP, a closing tag ?> implies a semi-colon. I agree it's good practice to include one - but that shouldn't be causing an issue.
Ive added the ; but it still isnt working. Ive updated my question.
@ColinMorelli Didn't knew that, Thanks a lot.
@ColinMorelli Should I delete this answer ?
@Ankit It's up to you, but I don't think you need to. I think the answer and comment might teach someone else something new as well. Go ahead and leave it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.