Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Replace a specific text value after call home_url

I just started the coding and can’t figure this out by myself. Plese help.

example in wordpress

<input type="text" name="old" value="<?php echo home_url(); ?>" />

printing- https://example.com

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Change printing value = http://example.net

Is it possible to change the printing value after calling the home_url in PHP without Jquery?

Thank you!

>Solution :

Use str_replace function inline; The home_url() return value to str_replace as input, then this function replace com to net, as you need.

<input type="text" name="old" value="<?php echo str_replace('com','net',home_url()); ?>" />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading