From 503651a6fe27b5925d77b1c5712a620be35a5718 Mon Sep 17 00:00:00 2001 From: JasperVanEck Date: Fri, 29 Nov 2013 13:02:30 +0100 Subject: Comment update --- Examples/Exceptions/exception.php | 22 +++++++++++----------- .../FunctionNoParameters/functionnoparameters.php | 8 +++----- .../FunctionReturnValue/functionreturnvalue.php | 5 ++--- 3 files changed, 16 insertions(+), 19 deletions(-) (limited to 'Examples') diff --git a/Examples/Exceptions/exception.php b/Examples/Exceptions/exception.php index 9c02286..81bbd50 100644 --- a/Examples/Exceptions/exception.php +++ b/Examples/Exceptions/exception.php @@ -1,25 +1,25 @@ * - * An example file to show the working of a function which throws an exception. + * @author Jasper van Eck + * + * This example shows the working of a C++ function that throws an + * exception, and that exception is then caught by PHP code. * - * Exceptions haven't been implemented yet. - * Therefore this example is not yet a working one. - */ - -/* - * Run a function which throws an exception. */ +// try-catch block to be able to handle the exception try { - echo "Function which throws an exception; my_throw_exception_function()\n"; - echo my_throw_exception_function() . "\n"; + // the my_throw_exception function is implemented in C++. and + // it is going to throw an exception + my_throw_exception_function(); } catch (Exception $exception) { + // the exception object is thrown by C++ code, and caught by PHP + // code echo $exception->getMessage(). "\n"; } diff --git a/Examples/FunctionNoParameters/functionnoparameters.php b/Examples/FunctionNoParameters/functionnoparameters.php index efaafc3..f4035ae 100644 --- a/Examples/FunctionNoParameters/functionnoparameters.php +++ b/Examples/FunctionNoParameters/functionnoparameters.php @@ -1,13 +1,11 @@ * * An example file to show the working of a function call without parameters. */ -/* - * Run a function without parameters. - */ -echo "A function which takes no parameters; my_no_parameters_function()\n"; + +//Run a function without parameters. echo my_no_parameters_function() . "\n"; diff --git a/Examples/FunctionReturnValue/functionreturnvalue.php b/Examples/FunctionReturnValue/functionreturnvalue.php index ba8f52b..1626e19 100644 --- a/Examples/FunctionReturnValue/functionreturnvalue.php +++ b/Examples/FunctionReturnValue/functionreturnvalue.php @@ -1,13 +1,12 @@ * * An example file to show the working of a function call with a return value. */ -/* +/** * Run a function which returns a value. */ -echo "Function which returns a value; my_return_value_function()\n" echo my_return_value_function() . "\n"; -- cgit v1.2.3