Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7854909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:13:42+00:00 2026-06-02T20:13:42+00:00

Just a simple question. I have a contact form stored in a function because

  • 0

Just a simple question. I have a contact form stored in a function because it’s just easier to call it on the pages I want it to have.

Now to extend usability, I want to search for {contactform} using str_replace.

Example:

function contactform(){
  // bunch of inputs
}

$wysiwyg = str_replace('{contactform}', contactform(), $wysiwyg);

So basically, if {contactform} is found. Replace it with the output of contactform.

Now I know that I can run the function before the replace and store its output in a variable, and then replace it with that same variable. But I’m interested to know if there is a better method than the one I have in mind.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:13:48+00:00Added an answer on June 2, 2026 at 8:13 pm

    Your method is fine, I would set it as a $var if you are planning to use the contents of contactform() more than once.

    It might pay to use http://php.net/strpos to check if {contact_form} exists before running the str_replace function.

    You could try both ways, and if your server support it, benchmark:

    <?php echo 'Memory Usage: '. (!function_exists('memory_get_usage') ? '0' : round(memory_get_usage()/1024/1024, 2)) .'MB'; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting started with Require.JS and I have a (hopefully) simple question. I'm
Simple question, I just want to select the text from the <Template> tag. Here's
I just wanted to ask a simple question - I have a class derived
Just a simple question, if i have several resource files for a page (contains
I just have one simple question. Everytime I use CGRectIntersectsRect(view1.frame, view2.frame) I get a
i just have a simple question to ask. For XML file, i know that
Just a simple php question, i have this: if(isset($_GET['i'])) { if($_GET['i']=='dash') { It is
Just a simple question on NSStrings, I have a piece of code that assigns
i just have a simple question on the output of the shell command.The below
Hello just really a simple question (I hope). I have a border used by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.