# Can i call a .php or .aspx files from rhtml page?

**URL:** <https://www.ruby-forum.com/t/can-i-call-a-php-or-aspx-files-from-rhtml-page/136549>\
**Category:** Rails\
**Created:** [May 3, 2008, 1:42pm UTC](https://www.ruby-forum.com/t/can-i-call-a-php-or-aspx-files-from-rhtml-page/136549 "2008-05-03T13:42:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratnavel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@ratnavel](https://www.ruby-forum.com/u/ratnavel)\
**Post date:** [May 3, 2008, 1:42pm UTC](https://www.ruby-forum.com/t/can-i-call-a-php-or-aspx-files-from-rhtml-page/136549/1 "2008-05-03T13:42:15Z")

</div>

I have some code written in php and that is placed in my public folder  
with .php extension.

Is there a way to call that file?

Thanks,  
Ratnavel.

---

<div class="post-metadata">

**Author:** ![ratnavel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@ratnavel](https://www.ruby-forum.com/u/ratnavel)\
**Post date:** [May 3, 2008, 3:44pm UTC](https://www.ruby-forum.com/t/can-i-call-a-php-or-aspx-files-from-rhtml-page/136549/2 "2008-05-03T15:44:49Z")

</div>

Ratnavel S. wrote:

> I have some code written in php and that is placed in my public folder  
> with .php extension.
> 
> Is there a way to call that file?
> 
> Thanks,  
> Ratnavel.

[1] Open app/helpers/application\_helper.rb  
[2] paste it under module ApplicationHelper

def link\_to\_file(name, file, \*args)  
if file[0] != ?/  
file = “#{@request.relative\_url\_root}/#{file}”  
end  
link\_to name, file, \*args  
end

[3] In your view, put it:

```
<%= link_to_file "teapoci file here", "teapoci.php" %>

```

Enjoy,  
[http://teapoci.blogspot.com](http://teapoci.blogspot.com)  
Reinhart

---

<div class="post-metadata">

**Author:** ![ratnavel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@ratnavel](https://www.ruby-forum.com/u/ratnavel)\
**Post date:** [May 5, 2008, 6:37am UTC](https://www.ruby-forum.com/t/can-i-call-a-php-or-aspx-files-from-rhtml-page/136549/3 "2008-05-05T06:37:32Z")

</div>

you could download the file and then print outs its results

On Sat, May 3, 2008 at 7:44 AM, Rails T.

---

<div class="post-metadata">

**Author:** ![ratnavel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@ratnavel](https://www.ruby-forum.com/u/ratnavel)\
**Post date:** [May 5, 2008, 11:47am UTC](https://www.ruby-forum.com/t/can-i-call-a-php-or-aspx-files-from-rhtml-page/136549/4 "2008-05-05T11:47:09Z")

</div>

On 3 May 2008, at 12:42, Ratnavel S. wrote:

> I have some code written in php and that is placed in my public folder  
> with .php extension.
> 
> Is there a way to call that file?

Do you just want the user to be able the view the result of executing  
that page (in which case it’s probably just a matter of setting up  
apache etc… properly) or do you want to execute the php code  
yourself and do something with the results yourself (in which case the  
easiest way may be to just run the file through the php executable).

Fred
