F
F
FilatovNikita2017-07-06 12:36:43
PHP
FilatovNikita, 2017-07-06 12:36:43

Why doesn't the try catch construct work?

I can't figure out why the try catch at the entry point doesn't work! Here is the source itself bfb74fe5d8b3456790ec6058c6a92684.png
. Through the passed url, I connect the necessary controller in the autolode, I set a check if! file_exists, then we catch an exception, the whole point is that this code works until I pass something like this in the url ( localhost/For_nout/ oop_blog/ssdsd---), and if, for example, I write in the url like this ( localhost/For_nout/oop_blog/ssdsd), then the exception is triggered. Thanks in advance, I don’t know what’s the catch here, I’ll be glad to discuss this topic!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Korobkov, 2017-07-06
@FilatovNikita

if !file_exists, then we catch an exception

Exactly the opposite. throw is "throw" and catch is "catch"
So this is not an Exception, but a Fatal error, it is not caught by try-catch.
new must be a valid name. Hyphens and other special characters are not allowed. $params0 needs to be cleared beforehand

S
stcmd04236, 2017-07-06
@stcmd04236

Because you're trying to upload a file that doesn't exist anyway. Throw an exception and then try to load the file even though it exists. And you are trying to handle the exception after spl_auto_load_register.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question