Tutorial by Examples: e

A basic function is defined and executed like this: function hello($name) { print "Hello $name"; } hello("Alice");
Functions can have optional parameters, for example: function hello($name, $style = 'Formal') { switch ($style) { case 'Formal': print "Good Day $name"; break; case 'Informal': print "Hi $name"; break; ...
Function arguments can be passed "By Reference", allowing the function to modify the variable used outside the function: function pluralize(&$word) { if (substr($word, -1) == 'y') { $word = substr($word, 0, -1) . 'ies'; } else { $word .= 's'; } } $w...
An object in PHP contains variables and functions. Objects typically belong to a class, which defines the variables and functions that all objects of this class will contain. The syntax to define a class is: class Shape { public $sides = 0; public function description() { ...
The standard requires that long double provides at least as much precision as double, which provides at least as much precision as float; and that a long double can represent any value that a double can represent, while a double can represent any value that a float can represent. The details of the ...
As to pass list into a subroutine, you specify the subroutine's name and then supply the list to it: test_subroutine( 'item1', 'item2' ); test_subroutine 'item1', 'item2'; # same Internally Perl makes aliases to those arguments and put them into the array @_ which is available within the s...
If you like to organize your project by keeping source files in different subdirectories, you should know that during a build qmake will not preserve this directory structure and it will keep all the ".o" files in a single build directory. This can be a problem if you had conflicting file ...
In views\site\form-submission.php <?php Pjax::begin(['id'=>'id-pjax']); ?> <?= Html::beginForm(['site/form-submission'], 'post', ['data-pjax' => '', 'class' => 'form-inline']); ?> <?= Html::input('text', 'string', Yii::$app->request->post('string'), ['class' =&gt...
public function actionFormSubmission() { $security = new Security(); $string = Yii::$app->request->post('string'); $stringHash = ''; if (!is_null($string)) { $stringHash = $security->generatePasswordHash($string); } return $this->render('form-submi...
When a migration is run, Django stores the name of the migration in a django_migrations table. Create and Fake initial migrations for existing schema If your app already has models and database tables, and doesn’t have migrations. First create initial migrations for you app. python manage.py mak...
public interface ISingleton : IDisposable { } public class TransientDependency { } public class Singleton : ISingleton { public void Dispose() { } } public class CompositionRoot : IDisposable, IHttpControllerActivator { private readonly ISingleton _singleton; // pass in a...
A simple Hello, World program without error checking: #include <unistd.h> /* For write() and STDOUT_FILENO */ #include <stdlib.h> /* For EXIT_SUCCESS and EXIT_FAILURE */ int main(void) { char hello[] = "Hello, World\n"; /* Attempt to write `hell...
The following example creates a unique index on the JobCandidateID column of the HumanResources.JobCandidate table of the AdventureWorks2012 sample database. The example then creates a default full-text catalog, ft. Finally, the example creates a full-text index on the Resume column, using the ft ca...
USE AdventureWorks2012; GO CREATE FULLTEXT CATALOG production_catalog; GO CREATE FULLTEXT INDEX ON Production.ProductReview ( ReviewerName Language 1033, EmailAddress Language 1033, Comments Language 1033 ) KEY INDEX PK_ProductR...
USE AdventureWorks2012; GO CREATE FULLTEXT INDEX ON Production.Document ( Title Language 1033, DocumentSummary Language 1033, Document TYPE COLUMN FileExtension Language 1033 ) KEY INDEX PK_Document_DocumentID ...
SELECT product_id FROM products WHERE CONTAINS(product_description, ”Snap Happy 100EZ” OR FORMSOF(THESAURUS,’Snap Happy’) OR ‘100EZ’) AND product_cost < 200 ; SELECT candidate_name,SSN FROM candidates WHERE CONTAINS(candidate_resume,”SQL Server”) AND candidate_division ...
Postmodern is a library to interface the relational database PostgreSQL. It offers several levels of access to PostgreSQL, from the execution of SQL queries represented as strings, or as lists, to an object-relational mapping. The database used in the following examples can be created with these SQ...
This example shows you a minimal way to create a Hello World page in Django. This will help you realize that the django-admin startproject example command basically creates a bunch of folders and files and that you don't necessarily need that structure to run your project. Create a file called ...
Steps to Reproduce (Turbo Forms, CRM 2015.1, --> CRM 2016.2) Form (with or without other required fields) has one field that is empty and required. Lose focus on the empty field ("title" in this example), this triggers the Field Notification Icon: Wire up onChange Handler for emp...
Your code can, and often should, throw an exception when something unusual has happened. public void WalkInto(Destination destination) { if (destination.Name == "Mordor") { throw new InvalidOperationException("One does not simply walk into Mordor."); } ...

Page 547 of 1191