开发者

If I use AJAX to run an external .PHP file, does it have access to my .PHP includes?

I'm sure this is a quickie. I have a PHP application I'm working on, and I'm designing the form validation/processing; the file will be called via AJAX.

My question is: when I call the form validation .PHP file via AJAX, will it have access to my previously declared .PHP includes?

For example, if I have a class User already included on the page calling the AJAX file, will I be able to call new User or User::authenticate inside my 开发者_StackOverflowform validation .PHP?

Thanks.


Each invocation of php stands alone. It has no knowledge of what ran before it.

And it makes no difference that it's ajax. ajax calls are identical to simply browsing to the page regularly. It's just another way to display it in the browser, not another way to run php.


if you include it in your validation .PHP file yes, otherwise no


AJAX won't have any access to your PHP, it will merely have access to the output of your PHP. On the other hand, your PHP script will definitely have access on the included files.

You will be able to call new User, and then User::authenticate, but not only the last one alone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜